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  Unable to connect to

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 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 focal main restricted
deb-src focal main restricted

deb focal-security main restricted
deb-src focal-security main restricted

deb focal-updates main restricted
deb-src 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 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 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.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

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

  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?

    Santosh Bhat


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.