Docker – Can’t access Django server

Your issue:

CMD ["python", "manage.py", "runserver", "8000"]

In order for it to work, you need to change it to:

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

and finally, go to http://127.0.0.1:8000/ in your browser.

Why? Well, Python thinks you’re exposing it on 127.0.0.1 when in reality you want the eth0 address, since that can change, and we don’t want to hard code it, we use 0.0.0.0 which means “ALL” interfaces.

Remember docker 127.0.0.1 is NOT your host 127.0.0.1, each docker container has it’s own loopback (means 127.0.0.1).

Extra: If you don’t want to write out 0.0.0.0 you can simply write 0 — does the same thing.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)