How to fix apt-get update error on Ubuntu

Ubuntu Linux system maintains a local database (so-called apt package index) of packages that are available from the repositories defined in /etc/apt/sources.list, or in /etc/apt/sources.list.d/. The apt package index can often become outdated as the packages contained in the repositories change, or new repositories are added to the system.

In order to update the local apt package index, you run:

$ sudo apt-get update

However, for various reasons you may encounter errors while updating the apt package index. Here are several ways to fix common apt-get update errors.

Hash Sum mismatch error

W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/vivid-updates/main/i18n/Translation-en  Hash Sum mismatch

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

This error can happen when fetching the latest repositories during "apt-get update" was interrupted, and a subsequent "apt-get update" is not able to resume the interrupted fetch. In this case, remove the content in /var/lib/apt/lists before retrying "apt-get update".

$ sudo rm -rf /var/lib/apt/lists/*
$ sudo apt-get update

If the above does not solve the problem, use the following commands instead.

$ sudo rm -R /var/lib/apt/lists/partial/*
$ sudo apt-get update

404 Not Found error

If you are getting "404 Not Found" error, and you are using a rather old Ubuntu release, there is a chance that the 404 error occurs because your Ubuntu installation is no longer supported.

To find out whether this is the case, first check which Ubuntu release you are using, by running:

$ cat /etc/lsb-release

Then check out the "End of Life" date of your Ubuntu release by referring to https://wiki.ubuntu.com/Releases

If your release has reached end of life (EOL), you need to modify /etc/apt/sources.list as follows, in order to avoid 404 errors during apt-get update. Replace CODENAME with the codename of Ubuntu release that you are using.

# Required
deb http://old-releases.ubuntu.com/ubuntu/ CODENAME main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ CODENAME-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ CODENAME-security main restricted universe multiverse

# Optional
#deb http://old-releases.ubuntu.com/ubuntu/ CODENAME-backports main restricted universe multiverse

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

2 thoughts on “How to fix apt-get update error on Ubuntu

  1. So so grateful that someone posted something that finally addressed my issue:

    "404 Not Found error

    If you are getting "404 Not Found" error, and you are using a rather old Ubuntu release, there is a chance that the 404 error occurs because your Ubuntu installation is no longer supported. "

    Kudos!
    I really wish I came across this page earlier on instead of wasting so much time.

    Again, many thanks for publishing this!

  2. Hello, I am having the "Some index files" error. I tried the first command, then "sudo apt-get update", and it gave me the same error. I tried the second one, and it says:

    cannot remove '/var/lib/apt/lists/partial/*': No such file or directory

    What do I do? I'm rather new to Linux, but I know the very basics.

Leave a comment

Your email address will not be published. Required fields are marked *