Linux apt get update 404

How to Fix Ubuntu/Debian apt-get 404 Not Found Repository Errors

When using the desktop version of Ubuntu you’ll eventually get or probably have the problem that apt-get update throws a lot «Failed to fetch 404 Not Found» errors. Additionally, you may have the same problem when running apt-get install . Don’t worry, it will be fixed in a minute.

The Problem

You may see messages like the ones below when executing apt-get update or apt-get install . That is because Ubuntu releases are only supported for 9 months. LTS (Long Term Support) releases have support for 5 years. Once support is cut for the version you’re using, you’ll see those error messages. Ubuntu moves the repositories to another server and the defined URL to reach the sources are no longer available on default location http://archive.ubuntu.com/ubuntu/dist/ .

$ sudo apt-get update Ign http://de.archive.ubuntu.com raring Release.gpg Ign http://de.archive.ubuntu.com raring-updates Release.gpg Ign http://de.archive.ubuntu.com raring-backports Release.gpg Ign http://security.ubuntu.com raring-security Release.gpg Ign http://de.archive.ubuntu.com raring Release Ign http://de.archive.ubuntu.com raring-updates Release Ign http://de.archive.ubuntu.com raring-backports Release … 404 Not Found [IP: 91.189.92.201 80] Err http://security.ubuntu.com raring-security/restricted Sources 404 Not Found [IP: 91.189.92.201 80] Err http://security.ubuntu.com raring-security/universe Sources 404 Not Found [IP: 91.189.92.201 80] Err http://security.ubuntu.com raring-security/multiverse Sources 404 Not Found [IP: 91.189.92.201 80] Ign http://de.archive.ubuntu.com raring-backports/main Translation-en Ign http://de.archive.ubuntu.com raring-backports/multiverse Translation-en Err http://security.ubuntu.com raring-security/main amd64 Packages … W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/raring/restricted/source/Sources 404 Not Found [IP: 141.30.13.30 80] W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/raring/universe/source/Sources 404 Not Found [IP: 141.30.13.30 80] W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/raring-security/main/source/Sources 404 Not Found [IP: 91.189.92.201 80] W: Failed to fetch http://de.archive.ubuntu.com/ubuntu/dists/raring/multiverse/source/Sources 404 Not Found [IP: 141.30.13.30 80] … E: Some index files failed to download. They have been ignored, or old ones used instead. 

How to Fix The Problem

There are two solutions to get your apt commands working again. First: upgrade the Ubuntu release. Second: update the sources url to the old package repositories. Both solutions are described below in more detail.

Читайте также:  Openvpn linux config file

Distribution Upgrade

The most simple solution is to upgrade your Ubuntu instance to the newest release:

If the distribution upgrade is not an option right now, you can update the sources url for the Ubuntu repositories to find the old packages.

Update Packages Url

You can use the sed command to update the sources in /etc/apt/sources.list file to the new location for old package repositories 2 .

Run the following command to update archive.ubuntu.com and security.ubuntu.com package repository 4 URLs with old-releases.ubuntu.com . Since the normal Ubuntu releases link to the archive.… and security.… URLs, the support will be removed after their live cycle of 9 months and respective repositories 3 moved to old-releases.… .

sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list **Linux Mint additionally requires the execution of this command:** sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list.d/official-package-repositories.list 

To check whether there are other files in /etc/apt/sources.list.d/ which need to be updated, use the following grep command.

grep -E 'archive.ubuntu.com|security.ubuntu.com' /etc/apt/sources.list.d/* 

That’s it. Now you can update your sources again.

  • 1 :Myles McNamara’s blog post saved me a lot of time to understand the problem and find a solution
  • 2 :Ask Ubuntu: Install Software From Old Repositories (sed command)
  • 3 :Ubuntu Old Releases
  • 4 :Ubuntu Current Releases

Get Notified on New Future Studio
Content and Platform Updates

Get your weekly push notification about new and trending
Future Studio content and recent platform enhancements

Источник

How to fix apt 404 Not Found error on Debian/Ubuntu

You may encounter a “404 Not Found” error when you want to install a package in a Debian-based host. The reason is quite obvious, the URLs for downloading the packages are not working anymore, thus 404. For example, I was getting 404 error in a fresh installation of Debian 11 when I was trying to install openssh-server .

sudo apt install openssh-server

The error looks like the following:

Err:1 http://deb.debian.org/debian bullseye/main amd64 openssh-sftp-server amd64 1:8.4p1-5 404 Not Found [IP: 199.232.150.132 80] Err:2 http://deb.debian.org/debian bullseye/main amd64 openssh-server amd64 1:8.4p1-5 404 Not Found [IP: 199.232.150.132 80] E: Failed to fetch http://deb.debian.org/debian/pool/main/o/openssh/openssh-sftp-server_8.4p1-5_amd64.deb 404 Not Found [IP: 199.232.150.132 80] E: Failed to fetch http://deb.debian.org/debian/pool/main/o/openssh/openssh-server_8.4p1-5_amd64.deb 404 Not Found [IP: 199.232.150.132 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

debian 11 returns 404 Not Found

How to Fix?

The Debian /etc/apt/sources.list file contains repository URLs for downloading any package. When the repository URLs are updated or redirected to other URLs, you will receive a 404 error. We need to update those URLs in our sources.list file.

Читайте также:  Вывести название файла linux

Step 1: Find the outdated or broken repository URLs

From the output of your apt command, you will find the broken URLs.

Step 2: Find the updated repository URLs

For example, typing http://deb.debian.org/debian on the browser redirects to http://ftp.debian.org/debian/ so we can update deb.debian.org to ftp.debian.org in /etc/apt/sources.list. You can find a list of all Debian mirrors here.

Step 3: Backup your sources file

cp /etc/apt/sources.list /etc/apt/sources.list.bak

Step 4: Use sed to update the sources.list file

sed -i 's/deb.debian.org/ftp.debian.org/g' /etc/apt/sources.list

The -i option tell sed to directly make the changes in the file.

The s stands for substitute

deb.debian.org is the text we want to replace

ftp.debian.org is the replacement or updated URL

g stands for global, meaning replace all occurrences

Step 5: Update the repository

Step 6: Install the desired package

sudo apt intall openssh-server

This should be enough to fix the issue

fixed apt 404 not found on debian

Conclusion

Finding the corrupted URLs in the source repository files (/etc/apt/sources.list) and replacing them with the proper URLs which are working should be enough to solve this error.

Источник

Оцените статью
Adblock
detector