GrepBoard/Manuals
605 manuals ·

Fix Temporary failure in name resolution on Linux

·Tested on Ubuntu 24.04 (Docker) · iputils 20240117 · DiG 9.18.39 · 2026-10·Test scope ↓·6 steps

Temporary failure in name resolution means the DNS server in resolv.conf did not answer. Query it with dig to tell a resolver fault from a network fault.

output
ping: example.com: Temporary failure in name resolution

The name is not missing; the DNS server listed in /etc/resolv.conf did not give an answer. Usually that server is down (including the local stub 127.0.0.53) or the listed address is unreachable, so query it directly with dig, compare with a public resolver, and the cause falls out.

A name that really does not exist gives a different message. The same ping prints Name or service not known:

console
$ ping -c1 no-such-host.example.invalidping: no-such-host.example.invalid: Name or service not known

In getaddrinfo(3) terms the first is EAI_AGAIN (the name server returned a temporary failure; try again later) and the second is EAI_NONAME (getaddrinfo(3)). curl reports both as curl: (6) Could not resolve host, so check again with ping or getent.

[1] Time the failure. The duration splits the causes in two.

console
$ time ping -c1 example.comping: example.com: Temporary failure in name resolution real	0m10.013s…
Time takenMeaning
About 10 secondsPackets go out to the server but nothing answers (unreachable address, firewall, network down)
Instant (milliseconds)Nothing listens on port 53 at that address (local stub stopped, empty resolv.conf)

Ten seconds is the resolv.conf default timeout of 5 seconds × attempts of 2 (resolv.conf(5)). With three servers listed it takes longer.

[2] Check what /etc/resolv.conf says. On Ubuntu it is usually a symlink, so also run ls -l /etc/resolv.conf to see the target.

console
$ cat /etc/resolv.confnameserver 192.0.2.53

nameserver 127.0.0.53 means the system uses the systemd-resolved local stub; any other address means queries go straight to that server. With no nameserver line at all, the man page says the resolver uses the name server on the local machine (127.0.0.1); in the test an empty file produced this error instantly.

[3] Query the listed server and a public resolver with dig and compare. If the public resolver answers and the listed server does not, the network is fine and the listed server is the problem.

console
$ dig example.com;; communications error to 192.0.2.53#53: timed out;; communications error to 192.0.2.53#53: timed out;; communications error to 192.0.2.53#53: timed out ; <<>> DiG 9.18.39-0ubuntu0.24.04.8-Ubuntu <<>> example.com;; global options: +cmd;; no servers could be reached$ dig @1.1.1.1 example.com +short172.66.147.243104.20.23.154

timed out is the "10 seconds" case from step [1]; connection refused is the "instant" case. If the public resolver also times out, check the path out of the host.

console
$ ping -c1 -W2 1.1.1.1PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.64 bytes from 1.1.1.1: icmp_seq=1 ttl=55 time=2.45 ms…

If pinging an IP works, routing is fine and only DNS is broken. If the IP fails too, the problem is the network (gateway, firewall), not DNS. Networks that block outside DNS, such as many corporate ones, will make the public resolver fail by design; ask the network team for the internal DNS address.

[4] If 127.0.0.53 gives connection refused, check that systemd-resolved is running. This is the stub address listed with no service behind it:

console
$ dig example.com;; communications error to 127.0.0.53#53: connection refused;; communications error to 127.0.0.53#53: connection refused;; communications error to 127.0.0.53#53: connection refused…;; no servers could be reached

On a real server, check the service with systemctl status systemd-resolved and the upstream servers the stub forwards to with resolvectl status. The upstream list is also in /run/systemd/resolve/resolv.conf (systemd-resolved.service(8)). If the service has stopped, start it again with systemctl restart systemd-resolved and read the journal for why it stopped.

[5] If the upstream servers are empty or wrong, fix them at the source. Editing /etc/resolv.conf directly can break the symlink and gets overwritten on reboot or DHCP renewal. On Ubuntu Server the source is netplan (nameservers in /etc/netplan/*.yaml) or systemd-resolved (DNS= in /etc/systemd/resolved.conf).

[6] Verify with getent after the fix. It resolves through the same path as applications (the hosts: order in /etc/nsswitch.conf), so it reflects real behavior better than dig.

console
$ getent ahosts example.com | head -2172.66.147.243  STREAM example.com172.66.147.243  DGRAM  

On failure it prints nothing and exits with code 2 (echo $?). If only one name fails and it is the server's own hostname, the problem is /etc/hosts, not DNS; see sudo: unable to resolve host. If the server answers but with status: SERVFAIL, continue with dig SERVFAIL and DNSSEC. If old answers persist after you fix the DNS settings, flush the cache — see Flush DNS cache on Linux. If you are running your own DNS server such as dnsmasq or Pi-hole on this host and it fails with port 53 Address already in use, see Fix port 53 Address already in use.

Check it with the dig output explainer tool ↗ — calculated in your browser.

#dns#resolv-conf#systemd-resolved#dig#getaddrinfo