This error occurs when apt cannot find a package or repository at the specified URL, typically due to outdated package sources, end-of-life Ubuntu versions, or incompatible PPA repositories. The solution involves updating your repository sources to point to valid repositories.
The "404 Not Found" error is an HTTP status code indicating that the requested resource does not exist at the specified URL. When apt encounters this error during `apt update` or package installation, it means one or more of your configured package repositories has an invalid or outdated URL. This commonly occurs when repository servers are moved, repositories are deprecated, or when using older distributions that have reached end-of-life (EOL). APT cannot proceed with updating or installing packages until you fix the invalid repository URLs.
First, determine what version of Ubuntu or Debian you are running. Use:
lsb_release -a
# or
cat /etc/os-releaseCheck if your version is still supported. Ubuntu LTS versions are supported for 5 years, standard releases for 9 months. Debian versions have different support timelines (e.g., Debian Jessie EOL was 2020-06-30, Stretch EOL was 2022-06-30).
Before making changes, create a backup of your current sources configuration:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backupThis allows you to restore the original if something goes wrong.
If you are running an EOL Ubuntu version (e.g., 16.04, 14.04), Canonical maintains an old-releases archive. Replace archive.ubuntu.com with old-releases.ubuntu.com:
sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.listThis redirects all repository requests to the archived repositories for your version.
If you are running an EOL Debian version (Jessie, Stretch, Wheezy), switch to the official Debian archive:
sudo sed -i -e 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.listFor Bullseye which is becoming EOL, ensure sources point to deb.debian.org before transitioning to archive.debian.org when EOL is reached.
Check /etc/apt/sources.list.d/ for third-party PPA repositories that may be causing 404 errors:
ls /etc/apt/sources.list.d/If you identify a problematic PPA, remove it:
sudo add-apt-repository --remove ppa:username/ppa-nameOr manually delete the file:
sudo rm /etc/apt/sources.list.d/problematic-repo.listFor Ubuntu users who prefer a graphical interface:
1. Open Settings → Software & Updates
2. Review the "Ubuntu Software" tab and check enabled repositories
3. Click the "Other Software" tab
4. Look for any third-party PPAs or repositories that might be invalid
5. Uncheck or remove entries that are causing 404 errors
6. Click "Close" to refresh the package index
This method is safer if you're unfamiliar with editing sources.list directly.
After fixing your repository sources, update your package lists:
sudo apt updateThis should now complete without 404 errors. If errors persist, you may have additional problematic repositories to address. The output will show which specific repositories are still failing.
If you continue to experience 404 errors even after fixing sources, clear the apt cache:
sudo apt cleanThen retry the update:
sudo apt updateClearing the cache removes outdated cached package information that might be causing issues.
If running in Docker, ensure you update package lists within the container before installing packages:
FROM ubuntu:16.04
RUN apt update && apt install -y curl build-essentialFor containers based on EOL versions, switch to old-releases first:
FROM ubuntu:16.04
RUN sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list && apt update && apt install -y curlThe 404 error specifically indicates an HTTP 404 response, distinct from connection timeouts or DNS failures. Repository 404 errors are permanent by nature—if a URL returns 404, it will continue to do so until the repository is restored. Different Ubuntu releases have different EOL timelines: Ubuntu 22.04 (Jammy) LTS is supported until 2027, while Ubuntu 20.04 (Focal) LTS is supported until 2025. Standard releases like 23.10 are only supported for 9 months. Debian follows a different model with Stable, Testing, and Unstable branches; Stable releases transition to Old-Stable for 1 year after the next release. When troubleshooting 404 errors, always check if your version is EOL first—this is the most common cause. For custom repositories or PPAs, verify the repository is compatible with your specific Ubuntu/Debian version and architecture (amd64, i386, arm64, etc.). Some repositories may not provide packages for all architectures, causing 404 errors for specific package architectures. In CI/CD pipelines, adding retry logic with exponential backoff can help when encountering temporary 404 errors caused by repository maintenance windows.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt