How do I fix a "Hash Sum mismatch" error when running apt-get update on Ubuntu 16.04?

February 22, 2018 2k views
DigitalOcean Ubuntu 16.04

Running apt-get update -y fails with the following error message:

root@somehost:~# apt-get update -y
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
...
Ign:25 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 Packages
Get:25 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 Packages [759 kB]
Err:25 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 Packages
  Hash Sum mismatch
Fetched 25.1 MB in 6s (3,638 kB/s)
Reading package lists... Done
E: Failed to fetch http://sfo1.mirrors.digitalocean.com/ubuntu/dists/xenial-updates/universe/binary-amd64/Packages.gz  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.

What does this error mean?
Where can I learn more?
How do I solve this problem?

Steps to reproduce

curl \
-s \
-X POST \
-H 'Content-Type: application/json' \
 -H "Authorization: Bearer $(lpass show --notes do_token)" \
 -d "{\"name\":\"somehost.com\",\"region\":\"sfo2\",\"size\":\"512mb\",\"image\":\"ubuntu-16-04-x64\",\"ssh_keys\":[\"$(ssh-keygen -E md5 -lf id_rsa.pub | awk '{ gsub(/MD5:/, "", $2); print $2 }')\"]}" \
 https://api.digitalocean.com/v2/droplets

# Recover IP Address of host

ssh -i id_rsa root@$IP apt-get update -y
1 Answer

Did you by chance happen to try to do this again? I'm thinking there was an issue with the mirrors themselves. I had this very exact same problem on multiple droplets just running "sudo apt update" -- but the issue seems to have been resolved for me.

  • I haven't had this happen recently, if it happens again I'll probably try to figure it out then and report back.

Have another answer? Share your knowledge.