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
-
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.8If
pingfails ordigtimes out, your DNS server is likely unreachable. -
Fix: If you’re using DHCP, restart your network interface:
sudo systemctl restart NetworkManagerOr, if you manage interfaces manually, restart the specific interface (e.g.,
eth0):sudo ifdown eth0 && sudo ifup eth0If you’ve manually configured DNS, ensure the IP addresses in
/etc/resolv.confare correct and reachable. For example, ifresolv.confcontains:nameserver 192.168.1.1Ensure
192.168.1.1is 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.
-
-
Incorrect
resolv.confConfiguration: Even if the server is reachable,resolv.confmight be misconfigured, pointing to non-existent or incorrect DNS servers. This can happen ifresolv.confis managed by a tool likeNetworkManagerorsystemd-resolvedand has been manually edited incorrectly.-
Diagnosis:
cat /etc/resolv.confLook for valid IP addresses. Common public DNS servers are
8.8.8.8(Google) and1.1.1.1(Cloudflare). -
Fix: If
NetworkManageris active:sudo nmcli dev show | grep DNSThis 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-resolvedis active (check withsystemctl status systemd-resolved):sudo systemctl restart systemd-resolvedThis 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.confand adding/modifyingDNS=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.
-
-
Firewall Blocking DNS Traffic: A local firewall (like
ufworfirewalld) 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 disableFor
firewalld:sudo systemctl stop firewalldIf 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 enableFor
firewalld:sudo firewall-cmd --zone=public --add-service=dns --permanent sudo firewall-cmd --reloadEnsure 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.
-
-
systemd-resolvedIssues: If your system usessystemd-resolvedfor DNS management, it can sometimes get into a bad state or not be configured correctly.-
Diagnosis:
systemctl status systemd-resolved journalctl -u systemd-resolved -fLook for errors in the status or logs. Check
/etc/resolv.conf– it should often be a symlink to/run/systemd/resolve/stub-resolv.confor/run/systemd/resolve/resolv.conf. -
Fix: Restart the service:
sudo systemctl restart systemd-resolvedIf
/etc/resolv.confis 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.confand recreate the symlink:sudo rm /etc/resolv.conf sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.confThen restart
systemd-resolved. -
Why it works: Restarting
systemd-resolvedreinitializes its DNS stub listener and DNSSEC validation, clearing temporary glitches. Re-establishing the symlink ensuresglibcapplications correctly usesystemd-resolved’s stub resolver.
-
-
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.confCheck 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.
-
-
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.1If 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 (vianmclior graphical tools) to reliable public servers like8.8.8.8and1.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.