How to Fix “W: Some index files failed to download.” Error In Ubuntu

Sometimes you might encounter the error “W: Some index files failed to download.” on Ubuntu when updating the system. Here’s an excerpt of the error.

W: Failed to fetch archive.ubuntu.com/ubuntu/dists/quantal-security/Release.gpg  Unable to connect to archive.ubuntu.com:http:

W: Some index files failed to download. They have been ignored, or old ones used instead.

From the first line, the error is indicative of a mirror that is down or unavailable. In this case, the mirror archive.ubuntu.com is unavailable for some reason.

How to fix “W: Some index files failed to download.” error In Ubuntu

Usually, the error should clear once the mirror is back online. However, since you cannot be certain how long it will take for the mirror to become available once again, the best method is to switch to a different mirror.

Here are a few fixes that you can take to resolve the error.

Solution 1: Revert to the Original Ubuntu Mirror

If you bump into this error, the first trick up your sleeve is to switch back to the original mirror. This involves creating a new sources list file from the sample source list file in /usr/share/doc/apt/examples/sources.list path.

You can have a peek at the sample source list file as shown:

$ cat /usr/share/doc/apt/examples/sources.list
Sample Output
# See sources.list(5) manpage for more information
# Remember that CD-ROMs, DVDs and such are managed through the apt-cdrom tool.
deb http://us.archive.ubuntu.com/ubuntu focal main restricted
deb-src http://us.archive.ubuntu.com/ubuntu focal main restricted

deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted

deb http://us.archive.ubuntu.com/ubuntu focal-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu focal-updates main restricted

But first, as is always recommended, make a backup copy of the sources lists as shown:

$ sudo mv /etc/apt/sources.list{,.backup}
$ sudo mv /etc/apt/sources.list.d{,.backup}

Next, create a new sources list file from the sample sources list file by following the steps below:

$ sudo mkdir /etc/apt/sources.list.d
$ sudo cp /usr/share/doc/apt/examples/sources.list /etc/apt/sources.list

Finally, update the repositories as shown.

$ sudo apt update

This restores all the mirrors and enables the ‘Main‘ repository which is supported by Canonical.

To install community-supported software packages, proprietary packages, and packages not available under a completely free license, you might consider enabling the following repositories:

  • Universe – Community-maintained free and open-source software.
  • Restricted – Proprietary drivers for devices.
  • Multiverse – Software restricted by copyright or legal issues.

To enable these repositories, invoke the commands below.

$ sudo add-apt-repository restricted
$ sudo add-apt-repository multiverse
$ sudo add-apt-repository universe

Then update your package lists.

$ sudo apt update

At this point, you should have both the Main repository and community-supported repositories at your disposal.

Solution 2: Select the Nearest Mirror from Official Ubuntu Mirrors

Alternatively, you might consider switching to the nearest mirror – which often happens to be the fastest mirror – relative to your geographical location.

The easiest approach is to ensure that the mirror defined within the sources list file includes the country code relative to your country of residence. For example, the Official United States mirror provided in /etc/apt/sources.list is:

deb http://us.archive.ubuntu.com/ubuntu focal main restricted

If your location is not in the United States, just overwrite the US country code with the appropriate country code. For instance, if you are located in Canada, replace us with ca as shown in the file as shown.

deb http://ca.archive.ubuntu.com/ubuntu focal main restricted

Once done, update the sources list as shown:

$ sudo apt update

Solution 3: Copy Sources List Contents from a Well Functioning System

Finally, the other way to resolve this error is to copy the contents of the sources list file from another functional Ubuntu system and paste them into your system’s sources list file. This is by far the easiest method of fixing this error.

The three methods outlined should help you resolve this nagging error on Ubuntu.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply
  1. Hi,

    I have a local apt-mirror repo setup and it is scheduled to pull from the upstream once a week. During the sync process, any calls to the repo fail.

    Is there any better way to handle this situation without affecting the production during the sync?

    Thanks,
    Santosh Bhat

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.