453

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.
Braiam
  • 69,112
Rob
  • 12,940

22 Answers22

543

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

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

then run:

sudo apt-get update
sorin
  • 10,135
Lorem
  • 5,729
138

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.

Robie Basak
  • 15,910
126

The easiest way to fix this is:

sudo apt-get clean
sudo apt-get update
realhu
  • 1,719
  • 1
  • 11
  • 8
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)

Amir Uval
  • 1,161
58

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.

m13r
  • 687
26

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:

Jorge Castro
  • 73,717
18

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
Musaffa
  • 343
11

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.

Trey
  • 212
  • 2
  • 7
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

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.

galoget
  • 3,023
habibun
  • 631
  • 1
  • 8
  • 20
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

Peter V. Mørch
  • 5,837
  • 4
  • 39
  • 41
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

user.dz
  • 49,176
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

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.

Mateo
  • 8,152
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
shgnInc
  • 4,431
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.

brad parks
  • 2,507
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!

Max Xu
  • 707
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  
    
karel
  • 122,292
  • 133
  • 301
  • 332
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.

galoget
  • 3,023
BiggJJ
  • 1,249