How to fix hash sum mismatch and size mismatch errors from apt-get / apt-cacher

July 27, 2008 - 18:59
We run apt-cacher to save bandwidth in our intranet. All Ubuntu systems in our office uses the apt-cacher server to update and upgrade. Recently we started getting the hash sum mismatch and size mismatch errors. After some dabbling with the settings and the files we figured out a simple solution for this problem. Whenever we were running apt-get update, apt-get upgrade or apt-get dist-upgrade we were getting these annoying show-stoppers. The exact errors we were receiving were of this form
W: Failed to fetch http://192.168.1.5:3142/ubuntu/..i386.deb Hash Sum mismatch
or 
W: Failed to fetch http://192.168.1.5:3142/ubuntu/...deb Size mismatch

Once we started getting this error for a package in one of the machines in the network, it reoccurred for the same packet on all the other machines in the network. So we figured that it had something to do with the apt-cacher and we forced a reload of the specific package by going to the apt-cacher repository(we have it at the default location - /var/cache/apt-cacher) and deleting the file with the name for which the error was triggered from within the var/cache/apt-cacher/private folder. This file is a flag which is used to indicate the download status of the specific package.

While doing research on this problem we also realized that a possible solution was to change the repository server to some other server than the one already setup, either manually by editing the sources.list file or by changing it from synaptic package manager. This was how we initially solved the problem to get going but we have a lot of systems and we had only limited bandwidth and we had to save the bandwidth.

We also realized that we started getting this problem once we setup the apt-cacher with expiry-time of 24 hours. It could possibly have been that the packages were updated in between and our cache had gotten stale. So a similar issue could happen when people use proxies or apt-on-cds for updating packages. Once we fixed the errors we set the expiry-time to 0 which meant that new packages.gz files are downloaded every time someone requested for an update/upgrade. Hope this helps.

Zyxware is a leading Drupal web development company in India which has its operations in US, UK, Canada, Australia and Middle East. We provide all kind of Drupal services including Drupal Commerce. If you have any query regarding this, please get in touch with us

Post your comments / questions

I found this article because I was experiencing the same problem.

My case turned out to be because, here at work, I'm behind the corporate firewall and needed to configure apt-get to use the proxy server (in Synaptic Package Manager -> Settings -> Network tab)

i am running ubuntu 8 at home, desktop.
i keep getting fetch fail, hash sum mismatch from updates.
do you think the above fix will work and if so could you generate a step by step walkthrough as i am new to linux and command line use.
george

You also need to check if you're running Dans Guardian. That software stops you updating your system.

try updating any package using the same source..for example, if u r using lock info which is downloaded from insanelyi, adding more plug in such as weather plug in must be from the same source from insanelyi as well...the same apps from different source has different packages, thats why updating or plugging in show some error...

su to root, then

#rm -f /var/cache/apt/partial/*
#rm -f /var/cache/apt/*.deb

*Do not remove the partial folder under /var/cache/apt

I saw this at http://paulpodolny.blogspot.com/2011/06/ubuntu-hash-sum-mismatch-workaro...

Pages