Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Connection betweetn docker containers

I am struggling with the connection of nginx and django (docker container)

My strategy is like this , run uwsgi http option and 8001 port. (not socket)

uwsgi --http :8001 --module myapp.wsgi --py-autoreload 1 --logto /tmp/mylog.log

then I confirmed wget http://127.0.0.1:8001 works.

but from, nginx, It can't connect somehow. (111: Connection refused) error

However from nginx wget http://django:8001 works.

How can I connect between containars

upstream django {
    ip_hash;
    server 127.0.0.1:8001;
}

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        proxy_pass  http://127.0.0.1:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

server_tokens off;

I am trying this config but, if I try this, my container doesn't launch.

log is like this 2020/03/24 08:24:04 [emerg] 1#1: upstream "django" may not have port 8001 in /etc/nginx/conf.d/app_nginx.conf:16

upstream django {
    ip_hash;
    server django:8001;
}

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        proxy_pass  http://django:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

server_tokens off;

my docker compose is very simple...

  nginx:
    image: nginx:1.13
    container_name: nginx
    ports:
      - "8000:8000"
    volumes:
      - ./nginx/conf:/etc/nginx/conf.d
      - ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
      - ./nginx/static:/static
    depends_on:
      - django

Finally thanks to helps. my server works. final conf is like this below.

remove upstream and use name 'django' instead of 127.0.0.1

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        proxy_pass  http://django:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

server_tokens off;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If they run in different containers, 127.0.0.1 is not the correct IP; use the name of the other container, e.g.

proxy_pass http://django:8001;

so Docker's internal DNS can route things.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!