The Temporary Failure in Name Resolution error on Linux means that the system couldn’t translate a hostname (like www.google.com) into an IP address. This usually happens when the system tries to talk to a DNS server and gets no response or an invalid one.

Common Causes and Fixes

  1. DNS Server Unreachable: The most frequent culprit is that your system can’t reach the DNS servers listed in your resolv.conf.

    • Diagnosis:

      ping 8.8.8.8
      dig www.google.com @8.8.8.8
      

      If ping fails or dig times out, your DNS server is likely unreachable.

    • Fix: If you’re using DHCP, restart your network interface:

      sudo systemctl restart NetworkManager
      

      Or, if you manage interfaces manually, restart the specific interface (e.g., eth0):

      sudo ifdown eth0 && sudo ifup eth0
      

      If you’ve manually configured DNS, ensure the IP addresses in /etc/resolv.conf are correct and reachable. For example, if resolv.conf contains:

      nameserver 192.168.1.1
      

      Ensure 192.168.1.1 is a valid IP address for your router or DNS server and that your machine can ping it.

    • Why it works: This forces the system to re-acquire network configuration, including DNS server addresses, from the DHCP server or re-apply the static configuration, re-establishing the route to the DNS server.

  2. Incorrect resolv.conf Configuration: Even if the server is reachable, resolv.conf might be misconfigured, pointing to non-existent or incorrect DNS servers. This can happen if resolv.conf is managed by a tool like NetworkManager or systemd-resolved and has been manually edited incorrectly.

    • Diagnosis:

      cat /etc/resolv.conf
      

      Look for valid IP addresses. Common public DNS servers are 8.8.8.8 (Google) and 1.1.1.1 (Cloudflare).

    • Fix: If NetworkManager is active:

      sudo nmcli dev show | grep DNS
      

      This shows DNS servers managed by NetworkManager. If they are wrong, you can set them:

      sudo nmcli con modify <connection_name> ipv4.dns "8.8.8.8,1.1.1.1"
      sudo nmcli con up <connection_name>
      

      Replace <connection_name> with your active network connection name (e.g., Wired connection 1).

      If systemd-resolved is active (check with systemctl status systemd-resolved):

      sudo systemctl restart systemd-resolved
      

      This will typically re-read configuration and fetch DNS servers from DHCP or static settings. You can also explicitly configure it by editing /etc/systemd/resolved.conf and adding/modifying DNS= entries, then restarting the service.

    • Why it works: This ensures that resolv.conf (or the underlying DNS resolver configuration) points to functioning DNS servers that can resolve hostnames.

  3. Firewall Blocking DNS Traffic: A local firewall (like ufw or firewalld) or a network firewall might be blocking UDP/TCP port 53, which DNS uses.

    • Diagnosis: Temporarily disable the local firewall to test. For ufw:

      sudo ufw disable
      

      For firewalld:

      sudo systemctl stop firewalld
      

      If resolution starts working, the firewall is the issue.

    • Fix: Allow DNS traffic through your firewall. For ufw:

      sudo ufw allow 53/udp
      sudo ufw allow 53/tcp
      sudo ufw enable
      

      For firewalld:

      sudo firewall-cmd --zone=public --add-service=dns --permanent
      sudo firewall-cmd --reload
      

      Ensure your network firewall rules also permit UDP/TCP traffic on port 53 to your DNS servers.

    • Why it works: DNS queries are sent and responses are received on port 53. Opening this port allows the necessary communication.

  4. systemd-resolved Issues: If your system uses systemd-resolved for DNS management, it can sometimes get into a bad state or not be configured correctly.

    • Diagnosis:

      systemctl status systemd-resolved
      journalctl -u systemd-resolved -f
      

      Look for errors in the status or logs. Check /etc/resolv.conf – it should often be a symlink to /run/systemd/resolve/stub-resolv.conf or /run/systemd/resolve/resolv.conf.

    • Fix: Restart the service:

      sudo systemctl restart systemd-resolved
      

      If /etc/resolv.conf is not a symlink managed by systemd-resolved, ensure it’s correctly configured or that the symlink is re-established. You might need to delete the static /etc/resolv.conf and recreate the symlink:

      sudo rm /etc/resolv.conf
      sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
      

      Then restart systemd-resolved.

    • Why it works: Restarting systemd-resolved reinitializes its DNS stub listener and DNSSEC validation, clearing temporary glitches. Re-establishing the symlink ensures glibc applications correctly use systemd-resolved’s stub resolver.

  5. Network Interface Not Fully Up/DHCP Lease Expired: The network interface might not have successfully obtained an IP address or DNS server information via DHCP, or its lease may have expired.

    • Diagnosis:

      ip addr show
      cat /etc/resolv.conf
      

      Check if your network interface has a valid IP address. If it’s 169.254.x.x, it indicates an APIPA address, meaning DHCP failed.

    • Fix: Renew the DHCP lease. If using dhclient:

      sudo dhclient -r <interface_name>
      sudo dhclient <interface_name>
      

      Or, restart the network service as mentioned in point 1.

    • Why it works: This forces the interface to re-request an IP address and DNS configuration from the DHCP server.

  6. DNS Server Issues (Remote): The DNS server itself (e.g., your router, ISP’s DNS, or a public DNS) might be having problems.

    • Diagnosis: Try resolving a hostname using a different DNS server:

      dig www.google.com @1.1.1.1
      

      If this works but your default DNS doesn’t, the issue is with your configured DNS server.

    • Fix: Change your DNS servers in /etc/resolv.conf (if not managed by DHCP/NetworkManager) or in your network connection settings (via nmcli or graphical tools) to reliable public servers like 8.8.8.8 and 1.1.1.1. If using DHCP, you might need to configure your router or DHCP server to hand out correct DNS server addresses.

    • Why it works: By pointing to a known-good DNS server, you bypass the problematic one and restore name resolution functionality.

After fixing these, you’ll likely encounter Errno 101 (Network is unreachable) if your network interface isn’t properly configured or connected.

Want structured learning?

Take the full Dns course →