How to Fix DNS 'Temporary Failure in Name Resolution' on Linux
'Temporary failure in name resolution' means your Linux server asked for a name and got no answer at all. On a real Ubuntu 24.04 server we follow the path every lookup takes and break it three ways: a fixed address in netplan with no DNS server, systemd-resolved switched off, and a firewall that blocks port 53. Plus why editing /etc/resolv.conf only works until the next restart, and why sudo says 'unable to resolve host'.
A number answers, a name doesn't
Your Linux server says: temporary failure in name resolution. But send a ping to 1.1.1.1, a plain number with no name to look up, and it answers in six milliseconds. So the network works. It can reach the internet. It just can't find anything on it. Why can a number get through, when a name can't? By the end, you'll know which step is broken and how to fix it so it stays fixed. And you'll fix the nastiest version too: the one where every lookup hangs for twenty seconds before it fails.
ping -c 1 archive.ubuntu.comping: archive.ubuntu.com: Temporary failure in name resolution
ping -c 2 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=63 time=6.47 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=63 time=7.72 ms --- 1.1.1.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1003ms rtt min/avg/max/mdev = 6.471/7.093/7.716/0.622 ms
What the message means
The error itself is a clue. Think of calling directory enquiries for a number. If the operator says there's no such listing, that's an answer: name or service not known. If the line to the operator is dead, you learn nothing at all: temporary failure. So we're not looking for a wrong name. We're looking for the dead line.

Ana runs the server for a bike courier depot. It's called dispatch, it plans the riders' routes, and this morning it can't even install updates. Every name it looks up takes the same path. The program reads /etc/resolv.conf, which on Ubuntu names one address: 127.0.0.53. That's systemd-resolved, a small service on the server itself. It passes the question on to a real DNS server, here the depot's own, and that one asks the internet. Temporary failure means nobody on that path answered.

The fix everyone posts
The fix you'll find first online: put a public DNS server in /etc/resolv.conf. Right now it says 127.0.0.53, under a comment that says do not edit. Ana writes nameserver 1.1.1.1 into it anyway. She uses tee, a command that writes into a file, with sudo, because root owns the file. And ping works. That's why it's the top answer.
cat /etc/resolv.conf# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8). # Do not edit. # # This file might be symlinked as /etc/resolv.conf. If you're looking at # /etc/resolv.conf and seeing this text, you have followed the symlink. # # This is a dynamic resolv.conf file for connecting local clients to the # internal DNS stub resolver of systemd-resolved. This file lists all # configured search domains. # # Run "resolvectl status" to see details about the uplink DNS servers # currently in use. # # Third party programs should typically not access this file directly, but only # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a # different way, replace this symlink by a static file or a different symlink. # # See man:systemd-resolved.service(8) for details about the supported modes of # operation for /etc/resolv.conf. nameserver 127.0.0.53 options edns0 trust-ad search .
echo 'nameserver 1.1.1.1' | sudo tee /etc/resolv.confnameserver 1.1.1.1
ping -c 1 archive.ubuntu.comPING archive.ubuntu.com.cdn.cloudflare.net (104.20.28.246) 56(84) bytes of data. 64 bytes from 104.20.28.246: icmp_seq=1 ttl=63 time=5.51 ms --- archive.ubuntu.com.cdn.cloudflare.net ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 5.510/5.510/5.510/0.000 ms
Guess first: after Ana restarts systemd-resolved, does her line stay? No. The restart puts 127.0.0.53 back, and the error with it. sudo printed a warning too; we'll come back to it. /etc/resolv.conf isn't really a file here. ls dash l shows it's only a shortcut to another file, and systemd-resolved rewrites that file every time it starts.
sudo systemctl restart systemd-resolvedsudo: unable to resolve host dispatch: Name or service not known
ping -c 1 archive.ubuntu.comping: archive.ubuntu.com: Temporary failure in name resolution
grep nameserver /etc/resolv.confnameserver 127.0.0.53
ls -l /etc/resolv.conflrwxrwxrwx 1 root root 39 Nov 19 14:44 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
Ubuntu's manual says it plainly. systemd-resolved maintains that file, and it lists 127.0.0.53 as the only DNS server. So an edit lasts until the next restart or reboot. The real question is behind 127.0.0.53: which server is systemd-resolved asking?

Who is it asking?
Before we look, one quick test proves it's a dead line and not a wrong name. Misspell the name, ubunto with an o, and you still get temporary failure, because nobody is there to say it doesn't exist.
ping -c 1 archive.ubunto.comping: archive.ubunto.com: Temporary failure in name resolution
resolvectl shows which DNS servers systemd-resolved is using. For the network card, eth0, the answer is none. No DNS servers at all. Ask it directly, and it says so: no appropriate name servers. systemd-resolved is running. It just has nobody to ask.
resolvectl status eth0Link 11 (eth0) Current Scopes: none Protocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolvectl query archive.ubuntu.comarchive.ubuntu.com: resolve call failed: No appropriate name servers or networks for name found
So where do DNS servers come from? On Ubuntu, from netplan, the file that sets up the network. Last week Ana gave this server a fixed address: the address, the route out through the depot's gateway, and nothing about DNS. Before, the network handed the server a DNS server along with its address. A fixed address gets only what you write.
sudo cat /etc/netplan/50-depot.yaml# The dispatch server's network: a fixed address on the depot's network, the router as the way out and as DNS. network: version: 2 renderer: networkd ethernets: eth0: addresses: [192.168.73.10/24] routes: - to: default via: 192.168.73.254
# nameservers: (missing)
The fix is two lines under the network card: nameservers, and the address of the depot's DNS server.
![Two lines for netplan: code change of /etc/netplan/50-depot.yaml, nameservers: (where to ask), addresses: [192.168.73.1] (the depot's DNS server)](/img/how-to-fix-dns-temporary-failure-in-name-resolution-on-linux/nsfix.jpg)
sudo netplan apply. Now resolvectl lists the depot's DNS server. ping finds the name, and apt updates. And the misspelled name? Now it gets a real answer: name or service not known. The operator picked up.
sudo netplan apply
resolvectl status eth0Link 11 (eth0) Current Scopes: DNS Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported DNS Servers: 192.168.73.1
ping -c 1 archive.ubuntu.comPING archive.ubuntu.com.cdn.cloudflare.net (172.66.152.176) 56(84) bytes of data. 64 bytes from 172.66.152.176: icmp_seq=1 ttl=63 time=8.60 ms --- archive.ubuntu.com.cdn.cloudflare.net ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 8.600/8.600/8.600/0.000 ms
sudo apt-get updateHit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease Hit:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease Hit:3 http://ports.ubuntu.com/ubuntu-ports noble-backports InRelease Hit:4 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease Reading package lists... Done
ping -c 1 archive.ubunto.comping: archive.ubunto.com: Name or service not known
Nobody at 127.0.0.53
A week later it's back. Someone followed a guide for an ad blocker that said: switch off systemd-resolved, it's using port fifty-three, the port DNS listens on. Now dig, a tool that asks a DNS server directly, gets connection refused from 127.0.0.53, three times. The file still sends every question there, and nobody is listening. systemctl status: disabled, inactive.
ping -c 1 archive.ubuntu.comping: archive.ubuntu.com: Temporary failure in name resolution
dig archive.ubuntu.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 ; <<>> DiG 9.18.39-0ubuntu0.24.04.9-Ubuntu <<>> archive.ubuntu.com ;; global options: +cmd ;; no servers could be reached
systemctl status systemd-resolved○ systemd-resolved.service - Network Name Resolution Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; disabled; preset: enabled) Active: inactive (dead) since Thu 2026-11-19 14:44:34 UTC; 4s ago Duration: 3.485s Docs: man:systemd-resolved.service(8) man:org.freedesktop.resolve1(5) https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients Process: 294 ExecStart=/usr/lib/systemd/systemd-resolved (code=exited, status=0/SUCCESS) Main PID: 294 (code=exited, status=0/SUCCESS) Status: "Shutting down..." CPU: 23ms Nov 19 14:44:31 dispatch systemd[1]: Starting systemd-resolved.service - Ne…n... Nov 19 14:44:31 dispatch systemd-resolved[294]: Positive Trust Anchors: Nov 19 14:44:31 dispatch systemd-resolved[294]: . IN DS 20326 8 2 e06d44b80b…c8d Nov 19 14:44:31 dispatch systemd-resolved[294]: . IN DS 38696 8 2 683d2d0acb…b16 Nov 19 14:44:31 dispatch systemd-resolved[294]: Negative trust anchors: home.ar… Nov 19 14:44:31 dispatch systemd-resolved[294]: Using system hostname 'dispa…h'. Nov 19 14:44:31 dispatch systemd[1]: Started systemd-resolved.service - Net…ion. Nov 19 14:44:34 dispatch systemd[1]: Stopping systemd-resolved.service - Ne…n... Nov 19 14:44:34 dispatch systemd[1]: systemd-resolved.service: Deactivated …lly. Nov 19 14:44:34 dispatch systemd[1]: Stopped systemd-resolved.service - Net…ion. Hint: Some lines were ellipsized, use -l to show in full.
The fix: enable it, and start it now. ping works again. But sudo complained once more that it can't find dispatch, this time with a temporary failure. We'll solve that next. If you really need port fifty-three for something else, that's the one case where you replace the shortcut with a real /etc/resolv.conf that names a DNS server that answers, because with systemd-resolved off, nothing rewrites it.
sudo systemctl enable --now systemd-resolvedsudo: unable to resolve host dispatch: Temporary failure in name resolution Created symlink /etc/systemd/system/dbus-org.freedesktop.resolve1.service → /usr/lib/systemd/system/systemd-resolved.service. Created symlink /etc/systemd/system/sysinit.target.wants/systemd-resolved.service → /usr/lib/systemd/system/systemd-resolved.service.
ping -c 1 archive.ubuntu.comPING archive.ubuntu.com.cdn.cloudflare.net (172.66.152.176) 56(84) bytes of data. 64 bytes from 172.66.152.176: icmp_seq=1 ttl=63 time=8.25 ms --- archive.ubuntu.com.cdn.cloudflare.net ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 8.251/8.251/8.251/0.000 ms
So why does sudo look up its own name? It checks which machine it's on before it runs anything. When Ana set this server up, it was called courier-pc. She renamed it dispatch last month. To see the warning clearly, she stops systemd-resolved for a moment, and runs sudo true, a command that does nothing. There's the warning. With the service stopped, only /etc/hosts can answer. That's a small file of names the server knows by heart, and it still lists the old name. Ana swaps in the new one, sudo goes quiet, and she starts systemd-resolved again.
sudo truesudo: unable to resolve host dispatch: Temporary failure in name resolution
grep 127.0.1.1 /etc/hosts127.0.1.1 courier-pc
sudo sed -i 's/courier-pc/dispatch/' /etc/hostssudo: unable to resolve host dispatch: Temporary failure in name resolution
sudo systemctl start systemd-resolved
When outgoing DNS is blocked
Then someone follows a guide to lock the server down: block everything going out, except web traffic. Guess first: how long does ping take to give up now? Twenty seconds, then the same temporary failure. When the error takes this long to arrive, the question is leaving the server, and nothing ever comes back.
time ping -c 1 debian.orgping: debian.org: Temporary failure in name resolution real 0m20.032s user 0m0.000s sys 0m0.002s
dig, asking the depot's DNS server directly: timed out, three times. The web still works: curl asks 1.1.1.1 for a web page, and a status code comes back. So web traffic gets out. Only DNS is stuck. ufw, Ubuntu's firewall, shows why: outgoing traffic is denied, except ports eighty and four forty-three for the web. DNS uses port fifty-three. Allow port fifty-three out. Now a web request to debian.org works again, because its name can be looked up.
dig @192.168.73.1 debian.org;; communications error to 192.168.73.1#53: timed out ;; communications error to 192.168.73.1#53: timed out ;; communications error to 192.168.73.1#53: timed out ; <<>> DiG 9.18.39-0ubuntu0.24.04.9-Ubuntu <<>> @192.168.73.1 debian.org ; (1 server found) ;; global options: +cmd ;; no servers could be reached
curl -sS -o /dev/null -w '%{http_code}\n' https://1.1.1.1301
sudo ufw status verboseStatus: active Logging: on (low) Default: deny (incoming), deny (outgoing), deny (routed) New profiles: skip To Action From -- ------ ---- 80/tcp ALLOW OUT Anywhere 443/tcp ALLOW OUT Anywhere
sudo ufw allow out 53Rule added
curl -sS -o /dev/null -w '%{http_code}\n' https://debian.org302
Find the broken step
So what's the fastest way to find the broken step next time? Walk the path in order. Does ping 1.1.1.1 answer? Then the network is fine. Is systemd-resolved running? Does resolvectl list a DNS server? And does your DNS server answer dig, at your own server's address? The first no is your broken step. Fix it in netplan, the service, or the firewall. Never in /etc/resolv.conf.

Recap
Temporary failure means no answer, not no such name. Prove the network with a number. Then check the service, its DNS server, and the way out to it.

If this got your server finding names again, subscribing helps a small channel reach more beginners. Every error here came from a real Ubuntu server, and the lab files are linked in the description. Thanks for watching Cloud Explainers.
Sources
- Ubuntu manual, systemd-resolved.service(8) (stub-resolv.conf lists 127.0.0.53 as the only DNS server and is maintained by systemd-resolved; it answers for the local hostname)
- Ubuntu manual, resolvectl(1)
- Netplan documentation, YAML configuration (nameservers: addresses)
- Ubuntu manual, getaddrinfo(3) (EAI_AGAIN: a temporary failure in name resolution; EAI_NONAME)
- Ubuntu manual, hosts(5)
- Ubuntu manual, ufw(8) (default deny outgoing; allow out)
Demos: containers on our own Mac standing in for a bike courier depot's server and router; the depot is made up. Every error was real, and every lookup that worked was a real one. Watch the full video on YouTube.