Dockerized django app not accessible via web

I am following a tutorial on how to dockerize django with postgres, gunicorn and nginx on an ubuntu 20.04 system. (see as reference: )

Unfortunately while setting up the nginx part of the app I’ve seem to have stumbled accross a problem with setting up the reverse proxy correctly.

When I try to access the django app via <ip-address>:1337 I get ‘The requested resource was not found on this server.’ error.

While I know that this is due to django not being properly served to nginx, but I’m quite new at web deployment and currently at a loss on how to proceed.

The relevant settings:

      context: ./app
    command: gunicorn hello_django.wsgi:application --bind
      - 8000
      - ./
      - db
    image: postgres:12.0-alpine
      - postgres_data:/var/lib/postgresql/data/
      - ./
    build: ./nginx
      - 1337:80
      - web



upstream hello_django {
    server web:8000;

server {

    listen 80;

    location / {
        proxy_pass http://hello_django;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;


nginx Dockerfile

FROM nginx:1.19.0-alpine

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d

ALLOWED_HOSTS = ['<ip-address>', 'localhost']

Any help would be really appreciated.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @mikewinkel !!

Did you, by any chance, find a solution to this particular problem?

I’m struggling with the same problem on a very similar docker django-gunicorn/nginx configuration and I can’t figure it out.

Thanks a lot!

Hi there @mikewinkel,

What I could suggest is checking the error log of both your Nginx and Web containers.

To do that you can run the following command:

  1. docker ps -a

This would return a list of your containers, and then get the container ID and check the logs:

  1. docker logs container_id_here

This will give you more information on why the services are not returning any responses.

Feel free to share the errors here if you wish.

Regards, Bobby