Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What the Error Means

The message comes from the system's resolver library, so any program can print it: ping: example.com: Temporary failure in name resolution, or apt reporting a temporary failure resolving a mirror. "Temporary" means the lookup got no answer, not that the name does not exist. A name that does not exist gives a different error; see ERR_NAME_NOT_RESOLVED for that side.

Name or Network?

First find out whether the network works at all. Find the gateway, then test an address without any name:

ip route
ping -c 3 GATEWAY_IP
getent hosts example.com

Use the address from the default via line; some gateways ignore ping, so a known public IP address also serves as a test. If the gateway answers and getent, which looks names up the way applications do, prints nothing, the network is fine and DNS is the problem. If there is no default route or the gateway does not answer, fix the network first, as the last section shows.

Look at the Resolver Configuration

Do not delete or overwrite /etc/resolv.conf. On many systems it is a link to a file another service manages. Look first:

ls -l /etc/resolv.conf
cat /etc/resolv.conf
resolvectl status

On Ubuntu, the file is normally a link to ../run/systemd/resolve/stub-resolv.conf and lists nameserver 127.0.0.53, the local systemd-resolved stub. resolvectl status then shows the real upstream servers under each interface. On AlmaLinux and Rocky Linux, NetworkManager writes the file with the upstream servers directly.

No Resolver Configured

If the file has no nameserver line, or resolvectl status shows no DNS servers, nothing tells the system where to ask. Set the servers in the network configuration, not in a generated file. On Ubuntu with netplan, edit the file in /etc/netplan/:

network:
  version: 2
  ethernets:
    eth0:
      nameservers:
        addresses: [RESOLVER_IP_1, RESOLVER_IP_2]

Use your interface name and your provider's or any public resolver's addresses, then apply with sudo netplan try, which rolls back unless you confirm. On AlmaLinux and Rocky Linux, find the connection with nmcli con show, set nmcli con mod CONNECTION ipv4.dns "RESOLVER_IP_1 RESOLVER_IP_2", and apply with nmcli con up CONNECTION, ideally from the console in your provider's control panel.

Resolver Unreachable or Blocked

dig example.com @resolver_ip

Put the configured server's address in place of resolver_ip. If dig reports a communications error that timed out, followed by "no servers could be reached", the queries do not get through. Check outgoing rules for port 53, UDP and TCP, with sudo ufw status verbose or sudo nft list ruleset, and any firewall in your provider's control panel. A resolver in a private network also stops answering when the server leaves that network.

systemd-resolved Stopped

When /etc/resolv.conf points to 127.0.0.53 and systemd-resolved is not running, nothing answers on that address and every lookup fails:

systemctl status systemd-resolved
sudo systemctl enable --now systemd-resolved

Read its log with journalctl -u systemd-resolved if it does not start.

A Broken Link

If ls -l shows a link whose target does not exist, the system has no resolver configuration. The target under /run is written by systemd-resolved, and /run is emptied at every boot, so after a reboot with the service disabled the link points nowhere. Start the service first and look again. If the link itself is wrong, back it up first (cp -P copies the link, not the file it points to) and point it back, on a system that uses systemd-resolved:

sudo cp -P /etc/resolv.conf /root/resolv.conf.bak
sudo ln -sf ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

No Network or Default Route

If ip route shows no default via line or the interface is down in ip -br addr, no lookup can work. This usually follows a network configuration edit or a changed IP. Use the console in your provider's control panel and correct the configuration. Lines in /etc/hosts still resolve without DNS, which is why getent hosts localhost works when nothing else does; see what is localhost.

Once lookups work, getent hosts example.com prints an address. To clear cached answers afterward, see how to flush the DNS cache in Linux.

Was this answer helpful?
Loading...