Resolving an APT 404 Not Found error on Ubuntu requires verifying your repository URLs in the /etc/apt/sources.list file or files within /etc/apt/sources.list.d/. This error typically occurs when a package component is misspelled, such as using "multiplex" instead of "multiverse," or when a third-party repository has changed its URL structure. Correcting these syntax errors and running sudo apt update restores access to the required package indexes.
Understanding the 404 Error in APT
When you runsudo apt install or sudo apt update, the Advanced Package Tool (APT) contacts remote servers defined in your configuration files to download package metadata. If a server returns a HTTP 404 status code, it means the specific resource requested does not exist at the provided location. In the context of Ubuntu, this is almost always a configuration issue rather than a network connectivity problem. The most common cause is a typo in the distribution codename or the component name within the source list entries.
For example, if you accidentally type multiplex instead of multiverse, APT will request a directory that the Ubuntu archive servers do not host. Since the server cannot find the path /dists/jammy/multiplex/main/binary-amd64/Packages, it returns a 404. Recognizing that this is a local configuration error allows you to fix it without needing to reinstall the operating system or contact server administrators.
Common Causes for Repository Failures
Several specific scenarios trigger this error during package management operations:- Misspelled Components: Typing invalid component names like
multiplex,contribs(instead ofcontrib), or incorrect suite names. - Deprecated Repositories: Using sources from older Ubuntu versions (e.g., Xenial, Bionic) on a newer release where those archives have been moved to old-releases.ubuntu.com.
- Third-Party PPAs: Personal Package Archives (PPAs) may become inactive, change their architecture support, or alter their URL structure after maintainer updates.
- Network Proxies: Corporate firewalls sometimes block specific ports or rewrite URLs, leading to misinterpreted responses.
Step-by-Step Troubleshooting Guide
To resolve the issue, you must identify which line in your configuration is causing the failure and correct it. Follow these steps carefully to restore your package manager functionality.1. Identify the Failing Source
First, run the update command with verbose output to see exactly which URL is failing. Open your terminal and execute:sudo apt-get update
Look for lines starting with Err or W that contain "404 Not Found". The output will show the full URL being accessed. For instance:
Err:1 http://archive.ubuntu.com/ubuntu jammy/multiplex InRelease
404 Not Found [IP: 91.189.91.39 80]
In this example, the component multiplex is clearly invalid. Note the exact URL and component name highlighted in red by your terminal.
2. Edit the Sources List
The main configuration file is located at/etc/apt/sources.list. However, many modern Ubuntu installations use additional files in /etc/apt/sources.list.d/. You should check both locations.
Open the main file using a text editor with sudo privileges:
sudo nano /etc/apt/sources.list
Search for the line containing the failed URL. If you see multiplex, change it to multiverse. The standard format for Ubuntu repositories is:
deb http://archive.ubuntu.com/ubuntu
Ensure that distribution matches your current release codename (e.g., jammy for 22.04, noble for 24.04). Ensure components are valid: main, restricted, universe, and multiverse.
If the error originates from a PPA or third-party source, check the files in /etc/apt/sources.list.d/:
ls /etc/apt/sources.list.d/
Open any relevant .list files and verify their URLs. If a PPA is no longer maintained, consider removing the file entirely.
3. Fix Deprecated Repositories
If you are trying to install packages from an older Ubuntu version, the standard archive servers may no longer host them. Ubuntu moves old releases toold-releases.ubuntu.com. If your sources list points to archive.ubuntu.com for an EOL release, you will get 404 errors.
Update the hostname in your sources list from archive.ubuntu.com to old-releases.ubuntu.com for any deprecated distributions. Save the file and exit the editor.
4. Clean and Update
After making changes, clear the local cache to ensure APT fetches fresh data:sudo apt clean
Then, attempt to update again:
sudo apt update
If the configuration is correct, the output should show Hit or Get statuses for all repositories without any Err lines. You can now proceed with installing your PHP packages or other software.
Preventing Future Errors
To avoid recurrence, always verify the compatibility of third-party repositories before adding them. Use official PPAs from trusted developers and check their documentation for the latest Ubuntu version support. When manually editingsources.list, copy existing valid lines as templates rather than typing URLs from memory. This reduces the risk of typos like multiplex versus multiverse. Additionally, keep your system updated regularly so that package managers remain synchronized with current repository structures.
If you are experiencing issues with PHP execution after fixing the repository errors, refer to our guide on PHP File Execution Not Working on Freshly Installed Ubuntu Unity (23.10) to ensure your web server configuration aligns with the installed packages.
Frequently Asked Questions
Why does apt update fail with 404 even though my internet works?
Your internet connection is likely functional because you can browse websites normally. The 404 error is specific to the APT tool requesting a non-existent file path on the Ubuntu servers. It indicates a mismatch between the URL configured in your system and the actual location of the package index files.How do I find out which Ubuntu release codename I am running?
You can determine your current release codename by running the commandlsb_release -cs in the terminal. This will output strings like jammy, focal, or noble. Use this output to ensure your sources.list entries match your active system version.
What should I do if a PPA gives me a 404 error?
If a Personal Package Archive returns a 404, it is likely discontinued or has changed its hosting provider. Remove the associated file from/etc/apt/sources.list.d/ using sudo rm /etc/apt/sources.list.d/.list . Then run sudo apt update to clear the error. Look for alternative PPAs or official Ubuntu repositories for similar functionality.
Can I fix the 404 error by changing my DNS settings?
Changing DNS settings rarely fixes a 404 error unless your current DNS is hijacking requests or blocking specific domains. A 404 is a response from the web server itself, meaning the server received the request but could not find the resource. Focus on correcting the URL syntax in your APT configuration first before troubleshooting network layers.Is it safe to delete the sources.list file?
It is not recommended to delete/etc/apt/sources.list entirely as it contains essential default repositories. Instead, comment out problematic lines by adding a # at the beginning. If the file is corrupted, you can regenerate it by running sudo add-apt-repository universe and other standard commands to rebuild the default configuration safely.