Fix 'Temporary Failure in Name Resolution' on Linux
Your server isn't dead—it just forgot how to read a phonebook. Learn what DNS and ping actually do, and how to fix 'Temporary failure in name resolution' on Linux and Docker.
You'll learn what DNS actually is (and why your server is having an existential crisis over it), how to use ping to prove your internet isn't actually dead, and how to fix Temporary failure in name resolution on Ubuntu/Debian hosts and Docker containers.
1. The big idea (your server forgot how to read)
There are few error messages more passive-aggressive than Temporary failure in name resolution. Nothing about it feels temporary, especially when apt update, curl, or your production API starts screaming at 2:00 AM.
Here is what is actually happening: computers do not talk to names like github.com. They talk to IP addresses—numeric street addresses like 140.82.114.4. DNS (Domain Name System) is just the internet's phonebook that translates human-friendly names into those IP addresses.
When Linux throws Temporary failure in name resolution, it is not saying "your internet is dead." It is saying "I tried to look up this domain in the phonebook, nobody answered, and now I refuse to go outside."
2. Prove your internet is alive in 10 seconds
Before you start tearing out network cables or blaming your ISP, we need to separate routing (can packets actually leave this machine?) from DNS (can this machine look up a name?).
We do that with ping—a tiny diagnostic tool that sends a "hello, are you alive?" packet to an address and waits for an echo back. If you ping a raw IP address like 1.1.1.1 (Cloudflare's public server), you skip the phonebook completely:
# 1. Test raw IP connectivity (bypasses DNS completely)
ping -c 2 1.1.1.1
# 2. Ask Linux to translate a domain name using its normal phonebook
getent hosts github.com || dig +short github.com
# 3. See who Linux thinks its phonebook operator is
ls -l /etc/resolv.conf && cat /etc/resolv.confHere is how to read the crime scene:
ping 1.1.1.1succeeds, butgetent hosts github.comfails: Your network is fine. Your server has full internet access—it just lost its phonebook.- Both fail: You have a deeper routing, Wi-Fi, or firewall problem, not just a DNS hiccup.
Think of /etc/resolv.conf as the sticky note taped to your server's monitor with the phone number of your DNS server (called a nameserver, like 1.1.1.1 or 8.8.8.8). If that file is empty, missing, or pointing at a dead local service, every domain lookup dies on arrival.
DNS Triage Flowchart (Quick Reference)Click to expandClick to collapse
ping -c 2 1.1.1.1resolvectl statussudo ufw statusEnsure outbound port 53 (UDP/TCP) is not blocked and Docker is not inheriting 127.0.0.53.
3. Resurrect systemd-resolved (and stop fighting resolv.conf)
On modern Ubuntu, Debian, and Fedora systems, Linux does not usually read /etc/resolv.conf directly as a static file. Instead, a background daemon called systemd-resolved acts as a local DNS middleman, listening on 127.0.0.53 and forwarding your lookups upstream.
When systemd-resolved crashes—or when someone overwrites the /etc/resolv.conf symlink—everything breaks at once:
# Check if the local DNS middleman is even alive
systemctl status systemd-resolved --no-pager
# See which upstream DNS servers it is actually using
resolvectl status
# Restore the official symlink if /etc/resolv.conf was clobbered
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolvedIf resolvectl status comes back looking bleak with no upstream DNS servers listed, give it a reliable fallback in /etc/systemd/resolved.conf:
[Resolve]
DNS=1.1.1.1 8.8.8.8
FallbackDNS=9.9.9.9Restart systemd-resolved once more, then test a lookup directly with resolvectl query github.com. If an IP address pops back, congratulations—your server can read again.
Confirm ping -c 2 1.1.1.1 gets 2 replies, resolvectl status shows a real upstream DNS server, and getent hosts github.com returns an IP address instead of silence.
4. Common pitfalls (ways people accidentally make it worse)
| Mistake | Why it backfires | Better fix |
|---|---|---|
Editing /etc/resolv.conf by hand | systemd-resolved or DHCP wipes your edit on reboot | Set DNS= in /etc/systemd/resolved.conf or Netplan |
| Forgetting outbound port 53 | DNS traffic travels over UDP/TCP port 53; strict ufw or cloud firewalls drop it silently | Allow outbound port 53 (sudo ufw allow out 53) |
Docker inheriting 127.0.0.53 | Inside a container, 127.0.0.53 points to the container itself, not the host's systemd-resolved | Set "dns": ["1.1.1.1", "8.8.8.8"] in /etc/docker/daemon.json |
Assuming ping failing means total outage | Many servers block ping (ICMP) for security while web/DNS traffic works fine | Verify with curl -I https://1.1.1.1 alongside dig |
5. What you learned
Temporary failure in name resolution sounds scary, but 90% of the time it is just a missing phonebook. By testing raw IP routing (ping 1.1.1.1) before blaming the whole network, checking /etc/resolv.conf, and keeping systemd-resolved (and Docker) pointed at real upstream DNS servers, you can bring a blind server back online in under a minute.