Ubuntu apt Hash Sum Mismatch

2015-07-26T11:00:32.999658-05:00 2015-08-23T09:51:39.150006-05:00

So today I was attempting to change some things up on one of our servers and running a normal SaltStack highstate was timing out and causing the minion process to basically just hang. After some investigation looking over the logs in /var/log/salt/minion it was obvious the issue was with apt-get updating it’s package listings.

But that’s strange, this box is on Digital Ocean and they have their own local mirrors. Turns out it’s a fairly common scenario with Ubuntu + mirrors + badly configured proxies. If you’re seeing things like this in your logs:

W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/utopic/universe/source/Sources: Hash Sum mismatch
Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/utopic-updates/main/binary-amd64/Packages: Hash Sum mismatch
: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/utopic-updates/universe/binary-amd64/Packages: Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.
E: Couldn't rebuild package cache

There is a pretty easy fix. You just need to clear our your existing apt source caches and re-update like this:

rm /var/lib/apt/lists/*
rm /var/lib/apt/lists/partial/*
apt-get update

This totally solved the issue for me. Not only unlocking/unsticking apt, but also making subsequent apt calls a touch faster. Hope this helps someone else!