How to Fix "Could Not Resolve Host" Error in apt-get Update
The "Could not resolve host" error in apt-get update means your system cannot translate repository hostnames into IP addresses. This is a DNS resolution problem that prevents package downloads. Here is how to fix it.
Fix 1: Check Network Connectivity
First, verify you have internet access. Run ping 8.8.8.8 to test basic connectivity. If this works but ping google.com fails, the issue is DNS resolution. If even the IP ping fails, you have a general network connectivity problem. Check your network cable, Wi-Fi connection, or network manager.
Fix 2: Configure DNS Settings
If DNS resolution is failing, configure your system to use reliable DNS servers. Edit /etc/resolv.conf with sudo nano /etc/resolv.conf and add nameserver 8.8.8.8 and nameserver 1.1.1.1. On systems using systemd-resolved, use sudo systemd-resolve --set-dns=8.8.8.8 --interface=eth0. On NetworkManager systems, edit the connection settings in the GUI or nmcli.
Fix 3: Check Repository URLs
Some repository hostnames may be outdated or incorrect. Check your sources.list file at /etc/apt/sources.list for typos in repository URLs. A common issue is using "archive.ubuntu.com" when your region requires a different mirror. Run sudo apt update and look for which specific host is failing.
Fix 4: Check Proxy Configuration
If you are behind a proxy server, apt needs proxy configuration. Configure HTTP and HTTPS proxy in /etc/apt/apt.conf.d/proxy.conf with Acquire::http::Proxy "http://proxy-address:port/"; and Acquire::https::Proxy "http://proxy-address:port/";. If your proxy requires authentication, include it in the URL.