Ubuntu apt Hash Sum Mismatch
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!
Frank Wiles
Founder of REVSYS, Django Steering Council, PSF Fellow, and former President of the Django Software Foundation .
Expert in building, scaling and maintaining complex web applications. Want to reach out? Contact me here or use the social links below.
Join my newsletter!
Get the occasional email from me when I write something new.
Struggling with architecture decisions or team dynamics? Ask me any tech, business process, or entrepreneurial question, and I'll do my best to help!