How to Fix ‘Temporary Failure in Name Resolution’ in Linux

Executing routine command-line operations on a Linux server or desktop—such as updating packages via apt update, cloning repositories with git, or requesting web endpoints using curl—can suddenly halt with the error: “Temporary failure in name resolution”. This diagnostic message indicates that the Linux glibc resolver library is unable to translate human-readable domain names (such as archive.ubuntu.com) into destination IP addresses via DNS. While the term temporary suggests an external internet outage, this fault is frequently caused by local network misconfigurations, broken resolver symlinks, or stalled DNS caching daemons. This technical guide outlines how the Linux DNS lookup pipeline functions and provides practical methods to resolve name resolution failures across Ubuntu, Debian, Fedora, and CentOS distributions.

Why Linux Reports ‘Temporary Failure in Name Resolution’

In modern Linux distributions, DNS lookups pass through several local components before reaching upstream recursive resolvers:

  • Misconfigured /etc/resolv.conf: The central resolver configuration file missing valid nameserver IP addresses or having invalid file permissions.
  • Broken systemd-resolved Symlink: On systemd-based distributions, /etc/resolv.conf is designed to be a symlink to the systemd-resolved stub. If this link is overwritten or disconnected, lookups fail.
  • Stalled DNS Daemon: The local caching service (such as systemd-resolved or dnsmasq) hanging or crashing in the background.
  • Firewall Dropping Port 53 Traffic: Local firewall rules (via ufw, iptables, or nftables) or upstream cloud security groups blocking outgoing UDP/TCP packets on port 53.
  • Static IP Misconfigurations: Network managers configured with a static IPv4 address lacking gateway or DNS server entries.

Method 1: Check Internet Connectivity and Ping IP Addresses

First verify whether the failure is strictly isolated to domain name resolution or represents total network interface disconnect.

  1. Open your Linux terminal.
  2. Attempt to ping a public IP address directly (bypassing DNS):
    ping -c 4 1.1.1.1
  3. If the ping succeeds with 0% packet loss, your network routing is healthy and the issue is strictly isolated to DNS resolution.
  4. If pinging the IP address fails with “Network is unreachable”, verify your physical interface, Wi-Fi association, or default gateway routing using:
    ip route show

Method 2: Inspect and Temporarily Update /etc/resolv.conf

Viewing the active resolver definitions reveals whether valid upstream nameservers are currently registered.

  1. Display the current resolver configuration:
    cat /etc/resolv.conf
  2. If the file is completely empty or contains dead internal IPs, open it in an editor with superuser privileges:
    sudo nano /etc/resolv.conf
  3. Add reliable public DNS nameservers to the file:
    nameserver 1.1.1.1
    nameserver 8.8.8.8
  4. Save the file by pressing Ctrl + O, then Enter, and exit with Ctrl + X.
  5. Test resolution immediately using ping -c 3 google.com. If it works, proceed to make the configuration persistent.

Method 3: Restart and Repair systemd-resolved

On modern Ubuntu, Debian, and Fedora systems, systemd-resolved manages local name resolution via a local stub listener at 127.0.0.53.

  1. Check the operational status of the service:
    systemctl status systemd-resolved.service
  2. If the service is inactive or degraded, restart it:
    sudo systemctl restart systemd-resolved.service
    sudo systemctl enable systemd-resolved.service
  3. Ensure /etc/resolv.conf correctly points to the systemd stub file:
    sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  4. Inspect active DNS servers recognized by the daemon:
    resolvectl status

Method 4: Configure Persistent DNS via Netplan (Ubuntu Server)

Manual edits to /etc/resolv.conf are overwritten by Netplan upon reboot. Configure persistent nameservers in Netplan configuration files.

  1. Navigate to the Netplan configuration directory:
    cd /etc/netplan/
    ls -l
  2. Edit the active YAML configuration file (e.g. 01-netcfg.yaml or 50-cloud-init.yaml):
    sudo nano /etc/netplan/01-netcfg.yaml
  3. Under your active interface (e.g. eth0 or enp3s0), define the nameservers block:
        ethernets:
          eth0:
            dhcp4: true
            nameservers:
              addresses: [1.1.1.1, 8.8.8.8]
  4. Preserve exact YAML indentation (use spaces, not tabs).
  5. Apply the new network configuration:
    sudo netplan apply

Method 5: Verify Firewall Rules for Outbound Port 53

If local security rules block outbound UDP or TCP traffic to port 53, DNS queries will time out.

  1. Check the status of Uncomplicated Firewall (UFW):
    sudo ufw status verbose
  2. If the default outgoing policy is set to deny, allow outbound DNS queries:
    sudo ufw allow out 53
  3. Test a direct DNS query using the dig or nslookup utility:
    dig @1.1.1.1 digitash.com
  4. If the query returns a valid answer section with an IP address, DNS communication is fully restored.

For additional Linux administration and server maintenance tutorials, visit the Digitash Terminal section.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.