The “404 Not Found” error during upgrade occurs when your system attempts to download packages from repository sources that no longer exist or have been moved, which typically happens with older Debian releases that have reached their end-of-life status and whose packages have been relocated to the archive servers.
Since Debian maintains strict release cycles, older versions eventually move from active mirrors to dedicated archive storage. When this happens, your existing repository configuration becomes outdated, and package manager operations fail.
Understanding 404 Errors During Upgrade
When you run apt-get update or apt-get upgrade, the system reads your sources list from /etc/apt/sources.list and attempts to fetch package information from the URLs specified there. If those URLs point to repositories that have been moved or removed, you receive 404 errors.
The solution involves updating your sources list to point to the correct repository locations. Since different Debian versions require different repository URLs, we will first identify your current version, then modify the configuration accordingly.
Checking Your Debian Version
Before making any changes, you need to determine which Debian version you are running.
lsb_release -a
The above command displays your distribution information, including the release number and codename.
- Bookworm → Debian 12
- Bullseye → Debian 11
- Buster → Debian 10
Make note of your codename, as you will need it in the following steps.
Backing Up Sources File Configuration
Since you will be modifying system files, creating a backup ensures you can restore your original configuration if needed.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
This creates a copy of your sources list in the same directory, if anything goes wrong, you can restore it by reversing the source and destination in the command above.
Updating Repository Sources
Next, you need to edit your sources list to point to the correct repositories. For older Debian releases that have reached end-of-life, you must switch to the archive servers.
Open the file with a text editor:
sudo nano /etc/apt/sources.list
For End-of-Life Debian Versions
If your Debian version is no longer supported (e.g., Jessie, Stretch, or older), replace the file contents with:
deb http://archive.debian.org/debian/ CODENAME main contrib non-free deb http://archive.debian.org/debian-security/ CODENAME/updates main contrib non-free
Replace CODENAME with your Debian codename (for example, stretch for Debian 9).
For Currently Supported Versions
If your Debian version is still supported but you’re getting 404 errors (mirror issues), use the main Debian repositories instead:
deb http://deb.debian.org/debian/ CODENAME main contrib non-free deb http://deb.debian.org/debian/ CODENAME-updates main contrib non-free deb http://security.debian.org/debian-security CODENAME-security main contrib non-free
Replace CODENAME with your version:
- Debian 12 → bookworm
- Debian 11 → bullseye
- Debian 10 → buster
After making these changes, save the file by pressing Ctrl+O, then Enter, and exit with Ctrl+X.
Handling Archive Repository Validation
Archive repositories for end-of-life Debian versions do not receive security updates, which means their release files are no longer signed with valid keys. To prevent apt command from failing due to expired signatures, you need to disable validation checks for these repositories.
Open or create the following configuration file:
sudo nano /etc/apt/apt.conf.d/99allow-unauthenticated
Add this single line:
Acquire::Check-Valid-Until "false";
This setting tells apt to ignore the validity period of release files, which is necessary for archived repositories that no longer receive updates.
Updating Package Information
With your repository sources now correctly configured, update your package lists, which will fetches the latest package information from your newly configured repositories. If everything is set up correctly, it should complete without any 404 errors.
sudo apt-get update
Once your package lists are updated, you can upgrade your installed packages, which will downloads and installs available updates for your current system. For archived versions, you may find that few or no packages are upgraded since they no longer receive updates.
sudo apt-get upgrade
Considering a Distribution Upgrade
While fixing the 404 errors allows your current system to function, running an end-of-life Debian version means you no longer receive security updates, which poses significant risks in production or internet-facing environments.
You should consider upgrading to a currently supported Debian release.
sudo apt-get dist-upgrade
However, upgrading between major Debian versions requires careful planning and should not be done casually, as it can break existing configurations or installed software. Consult the official Debian release notes for your target version before attempting a major upgrade.
Summary
The 404 errors during apt-get upgrade stem from outdated repository URLs in your sources configuration. By identifying your Debian version, updating your sources list to point to the appropriate repositories and adjusting validation settings can restore package management functionality.
Since running unsupported versions carries security implications, planning an upgrade to a current Debian release remains the recommended long-term solution.


