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

When executing package updates (sudo apt update), querying remote repositories, or executing curl and ping commands in Ubuntu Linux, the terminal may return an immediate failure: Temporary failure in name resolution. While the host computer often retains local link connectivity and can reach numerical gateway IP addresses, it cannot resolve fully qualified domain names into IP addresses. This disruption halts automated deployments, Docker container builds, and daily system management.

Fixing name resolution failures requires inspecting the status of the local DNS stub resolver (systemd-resolved), correcting broken /etc/resolv.conf symlinks, and assigning reliable upstream DNS nameservers.

What Causes ‘Temporary Failure in Name Resolution’ in Ubuntu?

In Ubuntu 20.04, 22.04, and 24.04 LTS, name resolution is orchestrated by systemd-resolved via a local loopback stub listener (127.0.0.53). Name resolution halts when:

  • systemd-resolved Service Stopped or Hung: The local DNS caching and stub resolution daemon is not active.
  • Corrupted /etc/resolv.conf Symlink: The traditional Unix resolver file has been replaced by a static file or points to a non-existent stub target.
  • Unreachable or Filtered Upstream DNS Servers: Upstream nameservers assigned by DHCP (such as local router resolvers) are timing out or filtering port 53 UDP traffic.
  • DNSSEC Validation Failures: Upstream DNS resolvers lack proper DNSSEC signing support, causing systemd-resolved to reject responses.
  • Netplan DNS Directive Omissions: Static IP configurations in Netplan lack declared nameservers blocks.

Step 1: Test Connectivity via Numerical IP vs Domain Name

Determine whether the issue is strictly isolated to DNS or represents a complete network routing collapse:

  1. Open a terminal and ping Cloudflare’s numerical DNS IP:
    ping -c 3 1.1.1.1
  2. If the numerical ping succeeds with 0% packet loss, your network routing and default gateway are functioning properly, confirming the fault is purely DNS.
  3. If the numerical ping fails with Network is unreachable, troubleshoot your physical interface and default gateway first before adjusting DNS.

Step 2: Restart and Inspect systemd-resolved

Restarting the systemd stub resolver flushes stale socket locks and reinitialises lookup threads:

  1. Check the operational status of the DNS daemon:
    sudo systemctl status systemd-resolved
  2. If the service is inactive or failed, start and enable it:
    sudo systemctl enable --now systemd-resolved
  3. Restart the service to flush runtime caches:
    sudo systemctl restart systemd-resolved
  4. Inspect current DNS servers bound to active interfaces:
    resolvectl status
    Verify that your primary interface (e.g. eth0 or enp3s0) lists valid DNS Servers.

Step 3: Recreate the /etc/resolv.conf Symlink

In modern Ubuntu systems, /etc/resolv.conf must be a symbolic link pointing to the systemd stub listener:

  1. Check the file type of your current resolver configuration:
    ls -l /etc/resolv.conf
  2. If it is a regular static file or broken link, remove it:
    sudo rm -f /etc/resolv.conf
  3. Recreate the correct symbolic link pointing to the systemd-resolved stub:
    sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  4. Restart the resolver service:
    sudo systemctl restart systemd-resolved

Step 4: Configure Upstream DNS Servers in resolved.conf

If your local router’s DNS server is unreliable, hardcode public DNS fallbacks directly in systemd configuration:

  1. Edit the main resolved.conf configuration file:
    sudo nano /etc/systemd/resolved.conf
  2. Locate the [Resolve] section and configure the following directives (remove leading # symbols):
    [Resolve]
    DNS=1.1.1.1 8.8.8.8
    FallbackDNS=1.0.0.1 8.8.4.4
    DNSSEC=no
  3. Save the file by pressing Ctrl + O, then exit with Ctrl + X.
  4. Restart the resolver to apply the new upstream nameservers:
    sudo systemctl restart systemd-resolved
  5. Test domain resolution immediately:
    ping -c 3 digitash.com

Step 5: Add Nameservers to Netplan Configuration

If your server uses static IP addressing configured through Netplan, declare nameservers explicitly:

  1. Open your Netplan YAML file:
    sudo nano /etc/netplan/01-netcfg.yaml
  2. Ensure your active interface configuration includes a dedicated nameservers block:
    nameservers:
      addresses: [1.1.1.1, 8.8.8.8]
  3. Apply changes cleanly:
    sudo netplan generate
    sudo netplan apply
  4. Run sudo apt update to confirm that all repository domains resolve without errors.

Get the best tech tips delivered straight to your inbox.

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