Applies to: apt on Ubuntu 24.04 LTS (apt 2.8.3) and Ubuntu 26.04 LTS (apt 3.2.0); the same messages and fixes apply to Debian
W: Failed to fetch means apt could not download a file from one of your repositories. The text after the address tells you why, and that decides the fix: Temporary failure resolving is a DNS problem, Could not connect is a network, firewall or proxy problem, 404 Not Found with "does not have a Release file" usually means your release has reached end of life, Hash Sum mismatch means a mirror or cache served a file that does not match, and is not valid yet means your server’s clock is wrong. apt then keeps the old package lists, or none, which is why the next install often fails too.
Start by running the update again and reading the lines that start with Err:, W: or E::
sudo apt update
Two things to know from our tests. With the apt command, apt 3 (Ubuntu 26.04, Debian 13) prints Warning: Failed to fetch instead of W: Failed to fetch; apt-get still prints W:. And apt update returned exit code 0 even when every repository failed, followed by "All packages are up to date". Do not trust that line until the warnings are gone.
Temporary failure resolving
Lab example (Ubuntu 24.04 container with a DNS server that does not answer):
Err:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease Temporary failure resolving 'archive.ubuntu.com' Reading package lists... W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/noble-security/InRelease Temporary failure resolving 'security.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
The server cannot turn the mirror’s name into an IP address. Check name resolution directly:
getent hosts archive.ubuntu.com cat /etc/resolv.conf
getent prints the address when DNS works and nothing (exit code 2) when it does not. Fix the DNS servers in your network configuration as shown in how to fix Temporary failure in name resolution, then run sudo apt update again.
Could not connect, Connection refused or timed out
DNS works but the connection fails: an outbound firewall, a network problem, or a proxy setting. Lab example with apt pointed at a proxy that is not running:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease Could not connect to 127.0.0.1:3128 (127.0.0.1). - connect (111: Connection refused) W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-updates/InRelease Unable to connect to 127.0.0.1:3128:
- Look for proxy settings apt uses. Remove or correct any line you do not need:
$ grep -ri proxy /etc/apt/apt.conf /etc/apt/apt.conf.d/ /etc/apt/apt.conf.d/95proxy:Acquire::http::Proxy "http://192.0.2.10:3128"; $ apt-config dump | grep -i proxy
Also check thehttp_proxyandhttps_proxyenvironment variables (env | grep -i proxy). - Test the mirror without apt. A working mirror answers
200 OK:$ curl -sI http://archive.ubuntu.com/ubuntu/dists/noble/InRelease | head -1 HTTP/1.1 200 OK
If this times out, outbound port 80 or 443 is blocked by a firewall (on the server, or in front of it) or the network is down. - If only IPv6 fails on your network, you can make apt use IPv4. According to the apt.conf manual,
Acquire::ForceIPv4forces downloads over IPv4:echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4
404 Not Found and "does not have a Release file"
When an Ubuntu release reaches end of life, its repositories are removed from the normal mirrors. Lab example with the sources of Ubuntu 23.10 (mantic), shortened:
Err:3 http://archive.ubuntu.com/ubuntu mantic Release 404 Not Found [IP: ... 80] Reading package lists... E: The repository 'http://archive.ubuntu.com/ubuntu mantic Release' does not have a Release file.
Check your release with grep -E '^(PRETTY_NAME|VERSION_CODENAME)' /etc/os-release. If it is no longer supported, the packages are still on old-releases.ubuntu.com. In our test, curl -sI returned 404 for mantic on archive.ubuntu.com and 200 on old-releases.ubuntu.com. Point apt there so you can install updates and then upgrade:
sudo cp /etc/apt/sources.list /root/sources.list.bak sudo sed -i -E 's#http://(archive|security)\.ubuntu\.com#http://old-releases.ubuntu.com#' /etc/apt/sources.list sudo apt update
After this change, apt update downloaded the mantic lists from old-releases.ubuntu.com without errors in our lab. Releases from 24.04 onwards keep their sources in /etc/apt/sources.list.d/ubuntu.sources instead; run the same sed on that file. An end-of-life release gets no security updates, so treat this as a step towards upgrading, not a fix. Ubuntu’s upgrade guide uses sudo do-release-upgrade and says LTS upgrades go one LTS release at a time, without skipping releases.
On Debian, Debian 10 and older are only on archive.debian.org (we got 404 for buster on deb.debian.org and 200 on archive.debian.org). Debian 11 is still on deb.debian.org. Our Debian sources.list article lists the correct lines for Debian 13 and 12; to move to a supported release, see how to upgrade from Debian 12 to 13.
The same "does not have a Release file" error on a supported release usually means a typo in the release name or a third-party repository that has no build for your release yet. Repositories on Ubuntu and how to add an APT repository cover those, along with NO_PUBKEY and "is not signed" key errors.
Hash Sum mismatch
apt checks every list file against the checksums in the repository’s signed Release file. A mismatch means the file you received is not the one the Release file describes, usually because the mirror was in the middle of a sync or a caching proxy served an old copy. We reproduced it in the lab with a local test repository whose Packages file we changed after signing (shortened):
Err:4 file:/srv/repo ./ Packages Hash Sum mismatch Hashes of expected file: ... E: Failed to fetch file:/srv/repo/./Packages Hash Sum mismatch E: Some index files failed to download. They have been ignored, or old ones used instead.
Clear the downloaded lists and try again a few minutes later:
sudo apt clean sudo rm -rf /var/lib/apt/lists/* sudo apt update
If it keeps happening, switch to another mirror or bypass the proxy or cache (for apt-cacher-ng, see update Ubuntu repositories and use a local mirror or apt-cacher-ng).
Release file is not valid yet
A wrong system clock makes apt reject correctly signed repositories. Lab example with the clock set back to 1 January 2024 (with faketime), shortened:
E: Release file for http://archive.ubuntu.com/ubuntu/dists/noble/InRelease is not valid yet (invalid for another 115d 15h 10min 21s). Updates for this repository will not be applied.
Check the time with timedatectl and turn on time synchronisation: how to synchronise time with NTP on Linux. Do not switch off apt’s date checks to hide the error.
Failed to fetch during apt install
If the error appears while installing rather than during apt update, your package lists are older than the mirror: the version apt wants to download has been replaced. Lab example (a local repository with the package file removed):
Err:1 file:/srv/repo ./ hello 2.10-3build1 File not found - /srv/repo/./hello_2.10-3build1_amd64.deb (2: No such file or directory) E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Do what the message says first: sudo apt update, then run the install again. --fix-missing only skips the missing packages, so it does not help when the missing file is the package you asked for.
Still failing?
- Run
sudo apt updateonce more and note which repository fails. If only one third-party repository fails, the rest of the system is fine; fix or disable that one file in/etc/apt/sources.list.d/. - If apt now says
Unable to locate package, see Unable to locate package on Ubuntu and Debian. - Ucartz customers can open a support ticket: a quick repository fix on a Ucartz VPS or dedicated server is covered by Free Basic Managed Support (best effort).
Related articles: update all packages on Linux safely, add, enable and remove repositories on Ubuntu, Temporary failure in name resolution and recover an interrupted dnf or apt transaction.
Official documentation: apt.conf(5) manual.