`dig api.internal` works, but the application and `curl` fail with `Could not resolve host: api.internal`.
IntermediateTroubleshootingNetworking, DNS and firewalls
Answer
Likely causes → dig queries DNS directly and skips NSS; apps use getaddrinfo() which follows /etc/nsswitch.conf, /etc/hosts and search domains. A bad hosts: line, or a .local/mDNS rule, or the app running in a different network namespace, can differ.
Diagnose →
getent hosts api.internal # uses the same path as apps
grep '^hosts' /etc/nsswitch.conf
cat /etc/resolv.conf # search, options ndots
Fix → Fix nsswitch (hosts: files dns), add the correct search domain, or fix the container's DNS config.
Prevent → Test with getent hosts, not dig, when debugging application resolution.
More on Networking, DNS and firewalls
`curl http://10.0.1.20:8080` returns `curl: (7) Failed to connect to 10.0.1.20 port 8080: Connection refused`.BeginnerThe same request instead hangs and ends with `curl: (28) Failed to connect to 10.0.1.20 port 8080 after 130000 ms: Connection timed out`. How is this different from "refused"?Beginner`ping google.com` fails with `ping: google.com: Temporary failure in name resolution`, but `ping 8.8.8.8` works.Beginner`/etc/resolv.conf` changes you made disappear after a reboot or a few minutes.BeginnerDNS lookups take exactly 5 seconds before succeeding.IntermediateShort names like `db01` don't resolve, but `db01.corp.example.com` does.Beginner