449

When I check for updates, I get a "Failed To Download Repository Information" error.

This is what comes up under details:

W: Failed to fetch gzip:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_natty_main_source_Sources  Hash Sum mismatch, 
E: Some index files failed to download. They have been ignored, or old ones used instead.
0

22 Answers 22

541

Just remove all the content of /var/lib/apt/lists directory:

sudo rm -rf /var/lib/apt/lists/*

then run:

sudo apt-get update
22
  • 89
    If you remove all files, you have to download them again. You can just remove the invalid file to make this process faster.
    – Behrang
    Jul 28, 2013 at 12:51
  • 12
    I remember this happening with Debian, too. The solution was to switch repositories (eg, from us.ubuntu.com to XX.ubuntu.com where XX is your country code) or waiting. The best idea would be to wait a bit and retry later. Removing the lists might fix broken lists, but that's rarely the case.
    – f.ardelian
    Jul 31, 2013 at 10:58
  • 8
    Old question, but on some distros (Like emdebian), after doing this you'll need to "mkdir /var/lib/apt/lists/partial" (As root, obviously.), or else you cannot "apt-get update" or otherwise use apt.
    – Archenoth
    Dec 26, 2013 at 3:48
  • 8
    @AlyssaGono if it's a folder, you need to run rm with the recursive flag like so: sudo rm -R /var/lib/apt/lists/* however, even doing that didn't work for me.
    – mchid
    Dec 11, 2014 at 3:33
  • 3
    We need prefix -rf, so it will look like sudo rm -rf /var/lib/apt/lists/*
    – Askar
    Feb 6, 2015 at 0:45
136

This is a known issue, and is exacerbated for clients behind proxy caches. Some large organisations and ISPs (especially in remote parts of the world) have transparent caches of which you may not be aware.

The fundamental issue is that the apt repository format is subject to race conditions when a mirror is updated. This problem particularly affects repositories that change rapidly, such as the development release.

You can track progress on the fix for this in this bug (please mark yourself as "affects me too" in the bug) and this blueprint. But be aware that it is a complex issue and may take more than one release to resolve.

7
  • 4
    That blueprint is no longer accessible; here's an archived copy. Apr 23, 2015 at 15:13
  • 18
    this bug also exists on ubuntu 16.04 Mar 31, 2016 at 19:34
  • 1
    The bug has been marked as "Fix Released".
    – user364819
    Apr 5, 2016 at 12:17
  • I just change my mirror default to the best server and its work for me.
    – habibun
    Jul 23, 2017 at 15:28
  • @habibun what do you mean by best server? I'm still facing to this issue even it's marked as Resolved. Do you guys have any workaround? none of apt-get clean, rm -rf /var/lib/apt/lists/* work for me even combined
    – irzhy
    Dec 28, 2020 at 21:07
124

The easiest way to fix this is:

sudo apt-get clean
sudo apt-get update
17
  • 14
    After trying the accepted answer I still had the same errors, trying this immediately afterwards fixed the issue
    – Alex
    Oct 21, 2015 at 10:50
  • 23
    Doing sudo rm -rf /var/lib/apt/lists/* then sudo apto-get clean fixed the problem for me also. Neither worked in isolation.
    – Cam
    Oct 29, 2015 at 23:27
  • 3
    does not help on ubuntu 16.04 ... neither does the comment above help any Mar 31, 2016 at 19:46
  • 3
    sudo apt-get clean did not help with 16.04, but sudo rm -rf /var/lib/apt/lists/* fixed it Aug 29, 2016 at 0:18
  • 2
    For me, accepted answer did not work, but this one worked (Ubuntu 16.04).
    – JCasso
    Jun 2, 2017 at 17:40
82

The only solution that worked for me is from unix.stackexchange.

It happens because there's a known bug it apt, and the solution is to update with a different compression method, so the files load correctly and the checksum succeeds.

Give this a try:

sudo rm -rf /var/lib/apt/lists/partial
sudo apt-get update -o Acquire::CompressionTypes::Order::=gz

(thanks @brook_hong from the comments for the rm part)

17
  • 12
    This is the only solution here that worked for me. Thanks.
    – Cerin
    Jun 21, 2016 at 17:53
  • 3
    It worked for me too. Note that you don't have to always run this command. Just run it once, and then you can run "apt-get update" without error.
    – dalf
    Jul 6, 2016 at 1:35
  • 2
    I tried using the generic solution from various forums but this works out of the box. Thank you.
    – khwilo
    May 26, 2018 at 14:41
  • 2
    Worked for me on Ubuntu 16.04/linux mint Jun 13, 2018 at 17:09
  • 4
    This is the only solution worked for me, am using Ubuntu 16.04 Sep 22, 2018 at 8:17
56

I still had the problem after removing the directories and doing sudo apt-get update.
Only the following step solved my problem:

sudo sed -i -re 's/\w+\.archive\.ubuntu\.com/archive.ubuntu.com/g' /etc/apt/sources.list

I don't know if this is the right way of fixing it...
I've found the solution here.

2
  • 3
    This was the only solution that works for me with Ubuntu 20.04.2 LTS. Thanks!
    – august0490
    Jul 23, 2021 at 14:53
  • I kept getting this problem with "hirsute-updates/universe amd64 DEP-11 Metadata" on Ubuntu 21.04, tried all the other answer and nothing worked... this solved it! Thanks @m13r! Aug 3, 2021 at 15:25
25

This can happen when your mirror is not up to date or serving errors from being overloaded. You can either wait a while and try again, or switch to another mirror:

3
  • 2
    Why does a server not being up to date, or being overloaded, cause a file with the correct name to successfully download (in the sense that the connection doesn't terminate until all the bytes are sent and received), but be corrupted? (I'm not asserting that doesn't happen, I'm just hoping you might be able to explain why it does.) Aug 13, 2012 at 21:30
  • 4
    @EliahKagan The problem normally is not that the file itself is corrupted, but that there is a (I am simplifying but not too much) data file and an index file containing the hash (fingerprint) of the data file. When the repositories are updated (happens every hour) on the server one file after the other gets updated. Now it can happen that your client (apt-get or similar) accesses the server when the data file has been updated but the index file has not been updated (or vice versa), yet. Then the hash doesn't match the data file and the client (falsely) assumes that the data file is corrupted. Apr 14, 2014 at 6:49
  • 1
    Changing the mirror worked for me when none of the above answers did.
    – mango
    Mar 25, 2016 at 16:16
16

If you're behind a proxy, then create a file named 99fixbadproxy in /etc/apt/apt.conf.d/:

sudo gedit /etc/apt/apt.conf.d/99fixbadproxy

Paste this into 99fixbadproxy and save it:

Acquire::http::Pipeline-Depth 0;
Acquire::http::No-Cache true;
Acquire::BrokenProxy    true;

Now run the update command:

sudo apt-get update
5
  • 2
    Wow, I was trying every answer, it is weird how many different issues seem to result in the same symptom.
    – dualed
    Jan 15, 2019 at 17:35
  • 2
    I am much indebted to this answer Feb 25, 2019 at 12:57
  • I had to do 'sudo rm -rf /var/lib/apt/lists/*' before 'sudo apt-get update' to make it work.
    – fivef
    Feb 10, 2020 at 12:21
  • no luck even with this advice :/ Jul 1, 2020 at 20:02
  • This is the only answer that worked for me. But @Musaffa I would like to know what these three lines actually do. Would you please explain? May 25, 2023 at 11:45
10

The accepted answer will rarely work if you have an issue with the CDN (content delivery network—the caches/mirrors around the world containing the apt lists and packages). It will work if a) you are using a PPA or local mirrors or b) have just a single mismatch to resolve.

Note: if you have the specific error message given in the log in the question above, the accepted answer should always work. But there are several other questions that have been closed as duplicates of this one where the accepted answer is insufficient.

It doesn't hurt to try, though, so start with:

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

This might be sufficient to proceed with sudo apt-get upgrade or other follow-up commands.

But if it doesn't work...

You may get "Hash sum mismatch" errors from that command, too. If this happens, run:

sudo apt-get update --fix-missing

It is possible that even this command will throw "Hash sum mismatch" errors, because the issue can come from transient network content errors. If so, continue to re-run the above --fix-missing command until it completes successfully. For example, like:

until sudo apt-get update --fix-missing; do echo trying again; done

(It should make progress with each run of apt-get update --fix-missing; if successive runs are not reducing the errors towards zero, press Ctrl-c to interrupt the loop. Then go back to the beginning of this answer with removing the contents of /var/lib/apt/lists and try again.)

After this, the update may work, but to be sure, first run apt-get clean, as so:

sudo apt-get clean
sudo apt-get update

Note that if you're doing this in preparation for an apt-get upgrade, it is possible (even likely, if you had enough mismatches to require updating several times) the upgrade will fail with "Hash sum mismatch" errors of its own. If so, add --fix-missing to your upgrade command:

sudo apt-get clean
sudo apt-get upgrade --fix-missing

and try again. (apt-get upgrade with --fix-missing will also try holding back failing packages and continuing others, so you should see some additional progress from running this at least once.)

But if it still doesn't work...

Like the earlier until sudo... command, you may get some further progress by repeating this command (always preceded by the clean command above), which you can even automate with

until (sudo apt-get clean; sudo apt-get upgrade --fix-missing --yes); do echo trying again; done

but, usually, it will upgrade most of the upgradable packages the first time you run it with --fix-missing and after that get stuck on the same packages, making no further progress. At that point, you'll need to go back up to the beginning with the sudo rm -rf /var/lib/apt/lists/* and try again. It is worth trying this whole process two or three times, especially if you have dozens or hundreds of upgradable packages.

5

The following commands may solve your issue.

sudo rm -R /var/lib/apt/lists/partial/*

and then

sudo apt-get update && sudo apt-get upgrade

it will solve your problem. I also faced the same problem but the above commands solved the problem for me. So give them a try.

Solution reference

1
  • 5
    I just tried, and it did not work; The first apt-get update created files in the same place again in that directory. Jan 23, 2015 at 11:17
4

I had the exact same problem and all solutions provided using the terminal did not help.

For me, it was by going into:

Settings → Software & Updates → Ubuntu Software: Download from: Change Local to Main Server.

It starts reloading the repos and updating. When I enter:

sudo apt-get update

After that, there was no problem at all. I'm using Ubuntu 14.04.4 LTS.

1
  • After changing Updates Download server to Main restart the computer and then run sudo apt-get update or sudo apt update . This fixed the issue in Ubuntu 20.04.
    – Eric kioko
    May 28, 2020 at 13:13
2

I don't know that it's proper solution or not, but I did the following and the error message's gone:

After typing sudo apt-get update in terminal, it gives me the names of some packages which cause the error then I did the following:

Update manager(software update) → Setting → Configure Software Sources → Other software[tab] → Uncheck the packages

After pressing the "close" bottom, update manager started to check for update automatically again and I saw this message:"the software on this computer is up to date. Last checked 2 seconds ago."

Kubuntu 12.04

2
  • This worked for me, and no other solution posted here worked. Except I don't have the Ubuntu UI (running command-line only under WSL), So instead, for each package <pkg> where the error occurred, I ran `sudo apt-get install <pkg>'. I am on Ubuntu 16.04.
    – Yitz
    Feb 20, 2018 at 13:29
  • If I understand correctly, this just stops the updates for that specific software altogether. This is hardly a solution, is it?
    – thymaro
    May 1, 2020 at 5:43
2

I had a similar problem and solved it by opening theh application "Software & Updates" and, in "Ubuntu Software" tab, changing the value of "Download from" (in that drop-down list, try to select, for example, Main Server if it was not like that).

1
  • Yes, only thing that worked for me. Switzerland server seems broken. Sep 4, 2017 at 14:26
2

If you're running Linux inside VirtualBox on Windows and have Hyper-V (or WSL 2, which uses Hyper-V) enabled at the same time, you're in for a world of pain. This being one symptom. VirtualBox 6.1 says on the tin that it supports Hyper-V but it just isn't true (as of 2020-08-25 windows v2040 at least). Disable Hyper-V and you're golden. From another answer:

In an elevated Command Prompt write this :

To disable:

bcdedit /set hypervisorlaunchtype off

To enable:

bcdedit /set hypervisorlaunchtype auto 

restart to take effect

1

I had the exact same problem and all solutions provided using the terminal did not help.

For me, it was by going into:

Settings → Software & Updates → Other software: Uncheck all the boxes and press close.

It starts reloading the repos and updating. When I enter:

sudo apt-get update

After that, there was no problem at all. I'm using Ubuntu 13.10.

1
  • This does work yet it effectively blinds the machine from being able to install packages not part of the core build (until those checkboxes are re-activated later) ... yet necessary at times just to achieve an error free apt-get update which enables install of targeted packages Apr 6, 2016 at 15:39
1

As follow @robie-basak, I used apt-cacher-ng as mirror caching. So I Remove the proxy and the problem solved.

I remove the proxy in file /etc/apt/apt.conf.d/01proxy:

#Acquire::http::Proxy "http://xxx.xx.xx.xx:4321";

Then need to:

sudo rm -rf /var/lib/apt/lists/*
sudo aptitude update
sudo aptitude upgrade
0
1

I had just recently install Ubuntu 17.10 and was getting the same error of Hash Sum Mismatch for a some repository.I went to Software and Checked Source as shown below and there were no problems further for downloading repository from the terminal.

My Software and Update Section

0

This can happen if you're running a router with parental controls, and havent put your raspberry pi into an "unmanaged" list. For me, I could see the url was redirecting to a circle domain, managed by the router.

So I just added my pi to the unmanaged list, and it worked fine.

0

I have resolved all the packages not being installed by running this command:

sudo apt-get install PACKAGENAME

For each of the packages. They are now installed and the "Hash Sum mismatch" error has gone.

0

Nothing worked for me. After trying and the suggested solutions, finally, I had downloaded the broken packages manually, copied them into /var/cache/apt/archives and removed the broken packages from /var/cache/apt/archives/partial.

0

I faced the same problem in my Ubuntu 18.04, below is my practical experience:

  1. Remove the proxy in /etc/apt/apt.conf
  2. Change to official apt sources.list /etc/apt/sources.list
  3. Run sudo rm -rf /var/lib/apt/lists/*
  4. Clean packages sudo apt autoremove -y && sudo apt autoclean -y
  5. Update and Upgrade. sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y

Done!

0

This happened for me on Ubuntu 16.04, and none of the top voted solutions worked. The solution was upgrading packages:

sudo apt-get update    # this will fail
sudo apt-get upgrade
sudo apt-get update    # this will succeed

Not sure if cleaning old lists (sudo rm -rf /var/lib/apt/lists/* and/or sudo apt-get clean) helped or not! Use them if necessary.

0

20190112 #Errors #apt #Fix #Updates Failed to fetch ... Hash Sum mismatch

  1. Run apt-get and find out what key words to search for in /etc/apt:
    • $ sudo apt-get -y update
    • ...
    • Err:77 http://au.archive.ubuntu.com/ubuntu xenial-updates/multiverse DEP-11 64x64 Icons
    • Hash Sum mismatch
    • ...
    • In this case, the keyword is "DEP-11"
  2. Search the /etc/apt tree for the keyword(s):
    • $ sudo find /etc/apt -type f -exec egrep -in "DEP-11" "{}" /dev/null ";"
    • /apt.conf.d/50appstream:1:## This file is provided by appstreamcli(1) to download DEP-11
    • /apt.conf.d/50appstream:6: deb::DEP-11  {
    • /apt.conf.d/50appstream:9: Description "$(RELEASE)/$(COMPONENT) $(NATIVE_ARCHITECTURE) DEP-11 Metadata";
    • /apt.conf.d/50appstream:15: # Normal-sized icons for GUI components described in the DEP-11
    • /apt.conf.d/50appstream:17: deb::DEP-11-icons {
    • /apt.conf.d/50appstream:20: Description "$(RELEASE)/$(COMPONENT) DEP-11 64x64 Icons";
    • /apt.conf.d/50appstream:27: # the DEP-11 YAML metadata.
    • /apt.conf.d/50appstream:28: deb::DEP-11-icons-hidpi {
    • /apt.conf.d/50appstream:31: Description "$(RELEASE)/$(COMPONENT) DEP-11 128x128 Icons";
  3. Having found the offending list, move it somewhere just in case this doesn't work:

    sudo mv -f /apt.conf.d/50appstream /tmp  
    
  4. Clean up /var/lib/apt:

    sudo apt-get -y clean  
    sudo rm -rf /var/lib/apt/lists/*  
    sudo find /var/lib/apt -type d -name "partial" -exec rm -rf "{}" ";"  
    
  5. Try to update now, it should work now:

    sudo apt-get -y update  
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .