Docker Network Nginx Resolver

0 votes

I am trying to get rid of deprecated Docker links in my configuration. What's left is getting rid of those Bad Gateway nginx reverse proxy errors when I recreated a container.

I am using the following configuration snippet inside nginx:

location / {
      resolver valid=30s;
      set $backend "http://confluence:8090";
      proxy_pass $backend;
  1. I started a container with hostname confluence on my Docker network with name nettest.
  2. Then I started the nginx container on network nettest.
  3. I can ping confluence from inside the nginx container
  4. confluence is listed inside the nginx container's /etc/hosts file
  5. nginx log says `send() failed (111: Connection refused) while resolving, resolver:``
  6. I tried the docker network default dns resolver from /etc/resol.conf
  7. nginx log says confluence could not be resolved (3: Host not found)

Can someone explain how to configure nginx resolver with docker networks.

Aug 1, 2018 in Docker by Hannah
• 18,570 points
Check your DNS nameserver

2 answers to this question.

0 votes

First off, you should be using the Docker embedded DNS server at

The reason for your problem could be one of these

  1. nginx is trying to use IPv6 (AAAA record) for the DNS queries.

Something like:

http {

    resolver ipv6=off;


This is probably no longer a problem with Docker 1.11:

Fix to not forward docker domain IPv6 queries to external servers (#21396)

  1. Take care that you don't accidentally override the resolver configuration directive. In my case I had in the server block resolver; from Mozilla's SSL Configuration Generator, which was overriding the resolver; in the httpblock. That had me scratching my head for a long time...
answered Aug 1, 2018 by Kalgi
• 52,360 points
Hey, I tried your solution, it's working for me. I am running nginx as a docker container inside Vagrant box. I cat /etc/resolv.conf .


options ndots:0

It will be great if you help me
Can you please explain the issue you're facing in detail?
0 votes
I had the exact same error. Funny story, I used the wrong IP address of the nameserver.
answered May 7, 2019 by Pallavi

Related Questions In Docker

0 votes
1 answer

Docker Swarm Overlay Network Communication

Try to recreate network like this : docker ...READ MORE

answered Aug 22, 2018 in Docker by Nilesh
• 7,050 points
0 votes
1 answer

Docker For Windows error: network adapters down

For testing, you can use the alternative ...READ MORE

answered Sep 24, 2018 in Docker by Tyrion anex
• 8,700 points
0 votes
1 answer

How to create a user-defined Bridge network in docker?

To create a user-defined bridge network, one ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,230 points
0 votes
1 answer

How to connect a docker container to user-defined bridge network?

When you create a new container, you ...READ MORE

answered Jul 3, 2019 in Docker by Sirajul
• 59,230 points
+1 vote
1 answer
+2 votes
1 answer
0 votes
1 answer

Network timed out while trying to connect to

This happened because docker virtual machine gets ...READ MORE

answered Jul 27, 2018 in Docker by Kalgi
• 52,360 points
0 votes
1 answer

Docker error "ERROR: for nginx Cannot start service nginx: oci runtime error"

I had faced a similar issue and ...READ MORE

answered Sep 24, 2019 in Docker by anonymous
• 52,360 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP