Nginx + dnsmasq = 'could not be resolved (5: Operation refused)' Nginx + dnsmasq = 'could not be resolved (5: Operation refused)' docker docker

Nginx + dnsmasq = 'could not be resolved (5: Operation refused)'


Your problem seems to be related to Nginx resolver directive configuration.By default, Nginx will try to resolve both IPv4 and IPV6 addresses. It will pick up first response from DNS server (dnsmasq in your case), cache it and fall down with an exception Operation refused, as it couldn't resolve DNS name to IPv6 address. The solution is add ipv6=off to your resolver directive, so it should look like this:

...resolver 127.0.0.1 ipv6=off;...

This will force Nginx to stop resolving DNS records to IPv6.