Executing sudo apt update or attempting to install software on an Ubuntu server, desktop, or cloud virtual machine only to be blocked by the error “Err:1 http://archive.ubuntu.com/ubuntu noble InRelease: Temporary failure resolving ‘archive.ubuntu.com'” or “W: Failed to fetch … Cannot initiate the connection” halts package management operations immediately. In Ubuntu and Debian systems, the APT package manager relies on system-level Domain Name System (DNS) resolver daemons (primarily systemd-resolved) to resolve repository domain names into routable IP addresses. When local DNS stub listeners crash, when /etc/resolv.conf contains broken symlinks or unreachable nameserver IP addresses, or when local network routers fail to forward UDP port 53 packets, APT cannot locate repository servers. This comprehensive technical guide explains how Ubuntu’s resolver subsystem functions and details step-by-step methods to restore domain name resolution.
Why Does apt-get Report ‘Temporary Failure Resolving’?
The error signifies that Ubuntu’s DNS resolver cannot convert the repository hostname into an IP address. Common triggers include:
- systemd-resolved Service Failure: Ubuntu’s native DNS caching service (
systemd-resolved.service) is stopped, deadlocked, or returning SERVFAIL responses. - Corrupted or Broken /etc/resolv.conf Symlink: In modern Ubuntu releases,
/etc/resolv.confmust be a symlink pointing to/run/systemd/resolve/stub-resolv.conf. A static or broken file severs communication with the resolver. - Unreachable DNS Nameservers: The nameservers assigned by DHCP (e.g. your local router or ISP gateway) are offline, timing out, or blocking outbound port 53 traffic.
- NetworkManager DNS Configuration Conflicts: Desktop environments where NetworkManager overrides systemd-resolved settings with empty nameserver strings.
- IPv6 Connectivity Blackholes: APT attempting to resolve or connect to repository servers via IPv6 when your local internet provider does not provide functioning IPv6 routing.
Method 1: Test Network and DNS Connectivity with ping and dig
Diagnose whether the issue is isolated to DNS resolution or reflects a total network disconnection.
- Open your Terminal (or access the server via console/SSH).
- Ping a public IP address directly to test raw IP connectivity:
ping -c 3 8.8.8.8 - If pinging
8.8.8.8succeeds, your physical network and gateway routing are functional. - Now test domain name resolution:
ping -c 3 archive.ubuntu.com - If pinging the IP succeeds but pinging the domain returns “Name or service not known”, the problem is strictly DNS resolution.
Method 2: Restart and Verify systemd-resolved
Restarting the local DNS stub listener clears stale or deadlocked query caches.
- Check the status of the systemd-resolved daemon:
systemctl status systemd-resolved - If the service is inactive or errored, restart and enable it:
sudo systemctl restart systemd-resolved sudo systemctl enable systemd-resolved - Flush local DNS caches:
sudo resolvectl flush-caches - Check active DNS servers:
resolvectl status - Re-run
sudo apt updateto test connectivity.
Method 3: Configure Static Public Nameservers in systemd-resolved
If your local router’s DHCP DNS servers are failing, adding reliable public resolvers (Cloudflare and Google) directly into the resolver configuration guarantees access.
- Open the systemd-resolved configuration file:
sudo nano /etc/systemd/resolved.conf - Locate the
[Resolve]section. - Uncomment or add the following lines:
[Resolve] DNS=1.1.1.1 8.8.8.8 FallbackDNS=1.0.0.1 8.8.4.4 - Save the file by pressing Ctrl + O and Enter, then exit with Ctrl + X.
- Restart the service to apply changes:
sudo systemctl restart systemd-resolved
Method 4: Fix the /etc/resolv.conf Symlink
If /etc/resolv.conf was accidentally replaced by an empty file or broken symlink, restoring the standard link fixes resolution.
- Inspect the current resolv.conf link:
ls -l /etc/resolv.conf - If it is a static file or points to a non-existent path, remove it:
sudo rm -f /etc/resolv.conf - Recreate the official symlink to the systemd-resolved stub file:
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf - If you need an immediate emergency temporary fix, create a static file:
sudo bash -c 'echo "nameserver 1.1.1.1" > /etc/resolv.conf' - Test running
sudo apt update.
Method 5: Force APT to Use IPv4
If your system attempts to query IPv6 DNS records over a network that lacks active IPv6 routing, APT hangs and times out.
- Instruct APT to connect exclusively via IPv4 for a single transaction:
sudo apt -o Acquire::ForceIPv4=true update - If this command succeeds immediately, make IPv4 enforcement permanent across all future APT transactions:
echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 - Future package installations and updates will now communicate reliably without DNS timeouts.