What the message looks like
$ ping example.com
ping: example.com: Temporary failure in name resolution
$ sudo apt update
Err:1 http://deb.debian.org/debian bookworm InRelease
Temporary failure resolving 'deb.debian.org'Common causes
/etc/resolv.confis empty, missing or points to a dead address, for example the stub127.0.0.53whilesystemd-resolvedis not running.- The network itself is down: no default route, no link, or the interface did not get its DNS servers from DHCP.
- A firewall blocks outgoing DNS on port 53 (UDP and TCP).
- In a container or VM the host passes no working DNS server to it.
- A VPN or a network manager rewrote the DNS settings.
Check
- Which DNS servers does the system use?
resolvectl status - What is in resolv.conf?
cat /etc/resolv.conf - Is there a default route?
ip route show default - Does the network work without DNS?
ping -c 2 1.1.1.1
Fix
- If the ping to the IP also fails, fix the network first (cable, DHCP, gateway, firewall). This is not a DNS problem then.
- Restart the resolver:
sudo systemctl restart systemd-resolvedand checksystemctl status systemd-resolved. - Restore the link to the managed file:
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf. This replaces the current file, so look at it first. - Set DNS servers permanently where the network is configured (netplan, systemd-networkd, NetworkManager or
/etc/network/interfaces), not by editingresolv.confby hand. - Allow outgoing UDP and TCP port 53 in the firewall.
Typical scenario
A container on your server cannot run apt update: "Temporary failure in name resolution". On the host itself name resolution works. Inside the container /etc/resolv.conf contains only nameserver 127.0.0.53, but no resolver runs there, because the stub resolver belongs to the host. Check with ping -c1 1.1.1.1 inside the container whether the network works at all; if that answers, it is only the DNS configuration.
FAQ
Is this the same as NXDOMAIN?
No. NXDOMAIN is an answer: the name does not exist. Here there is no answer because the resolver cannot be reached or is not set up.
It worked a minute ago. What changed?
Often a DHCP renewal, a VPN or network manager change, or a stopped systemd-resolved. Check resolvectl status and the log with journalctl -u systemd-resolved.
Why does nslookup work but ping does not?
nslookup and dig query a DNS server directly, either from resolv.conf or the one you give. ping uses the C library's resolution, which knows several sources through /etc/nsswitch.conf, such as the hosts file, systemd-resolved or mDNS. If only one works, the chain in between is broken.
How do I test the DNS server separately from the system resolver?
With dig @1.1.1.1 example.com you ask a specific server and bypass the local configuration. If it answers, the network is fine and the problem lies with the local resolver. resolvectl query example.com, by contrast, tests the path through systemd-resolved.
Why does the error occur only in Docker containers?
Containers take DNS settings from the host or from Docker's configuration. If Docker finds only a local stub address such as 127.0.0.53 on the host, it is useless inside the container network. The --dns option or the dns entry in daemon.json, which supplies a reachable address, then helps.