How to fix "Hash Sum mismatch Hashes of expected file" on Linux

I type apt-get update and apt-get upgrade but getting Hash Sum mismatch Hashes of expected file error. Here is output from Debian 10 server:

N: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Version' value from '10.10' to '10.11'
E: Failed to fetch http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/621d5053cc12eafc688e2c6f1ace9e421ad848c571a76d6bf3528183eec186f1  Hash Sum mismatch

  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:3e144c4ca83ab5689e54ce18f4c327f7cec6025160b17bea45136c013d1b8350
   - MD5Sum:43694c38321c0668c6d82b4e58fbd2e8 [weak]
   - Filesize:69920 [weak]
  Hashes of received file:
   - SHA256:bc041a5e876222f693ed1de063ff3ea7659d26d99fa1e0fb96689767d1c7bc0e
   - MD5Sum:16a5d63735af0f6b7d58754e37c5b794 [weak]
   - Filesize:69920 [weak]
  Last modification reported: Sun, 03 Oct 2021 14:40:07 +0000
Get:2 http://deb.debian.org/debian buster/main amd64 debconf-i18n all 1.5.71+deb10u1 [206 kB]
Err:2 http://deb.debian.org/debian buster/main amd64 debconf-i18n all 1.5.71+deb10u1
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:7e4872cdda720162fbb28021cd27d122995f1112f9e86c5275aa23fc8bfd13b8
   - MD5Sum:2441e001ddd8e326d9d1b3dda277f73d [weak]
   - Filesize:206208 [weak]
  Hashes of received file:
   - SHA256:4655c379569e576947f3036d7a21721b9af6dceb3544a9c7f271fd97b45a9464
   - MD5Sum:d2a1268e9954604241486463d5bf0298 [weak]
   - Filesize:206208 [weak]
  Last modification reported: Fri, 01 Oct 2021 20:41:59 +0000
Get:3 http://deb.debian.org/debian buster/main amd64 python3-debconf all 1.5.71+deb10u1 [4,028 B]
Err:3 http://deb.debian.org/debian buster/main amd64 python3-debconf all 1.5.71+deb10u1
  Hash Sum mismatch
  Hashes of expected file:
   - SHA256:ae9202bade8b7cc0e1fcf658598c710509dd7c159d88d9a3abea7fbb34020ba5
   - MD5Sum:54736a2fa1be1302f93adc73e273b7d2 [weak]

   Last modification reported: Tue, 13 Jul 2021 20:25:12 +0000
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

How to fix it?

You need to remove all old hashes from the /var/lib/apt/lists directory and then try again.

Troubleshoot downloading packages list due to a “Hash sum mismatch” error on Debian and Ubuntu Linux

  1. Login as the root user (use the su - or sudo -i command):
    sudo -i
  2. Cd into /var/lib/apt/lists:
    cd /var/lib/apt/lists/
  3. Remove all files using the rm:
    rm -rfv *
  4. Then run the following as you removed all the content of /var/lib/apt/lists directory to to download package information from all configured APT sources (apt clean to clears out the local repository of retrieved package files):
    apt clean && apt update
  5. Finally apply upgrades:
    apt upgrade
  6. Reboot the Debian/Ubuntu Linux when critical updates including a new kernel installed by the apt:
    reboot
1 Like

How do I fix hash sum mismatch?

Thank you @monk but I used apt-get instead of apt and it worked like a charm

sudo rm -rfv /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-image-4.19.0-18-amd64
The following packages will be upgraded:
  base-files debconf debconf-i18n distro-info-data krb5-locales libgssapi-krb5-2 libk5crypto3 libkrb5-3 libkrb5support0 linux-image-amd64 psmisc python3-debconf shim-helpers-amd64-signed shim-signed shim-signed-common
  shim-unsigned tzdata
17 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 51.1 MB/51.2 MB of archives.
After this operation, 270 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian buster/main amd64 base-files amd64 10.3+deb10u11 [69.9 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 debconf-i18n all 1.5.71+deb10u1 [206 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 python3-debconf all 1.5.71+deb10u1 [4,028 B]
Get:4 http://deb.debian.org/debian buster/main amd64 debconf all 1.5.71+deb10u1 [145 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 tzdata all 2021a-0+deb10u2 [266 kB]
Get:6 http://deb.debian.org/debian buster/main amd64 krb5-locales all 1.17-3+deb10u3 [95.5 kB]
Get:7 http://deb.debian.org/debian buster/main amd64 libgssapi-krb5-2 amd64 1.17-3+deb10u3 [158 kB]
Get:8 http://deb.debian.org/debian buster/main amd64 libkrb5-3 amd64 1.17-3+deb10u3 [370 kB]
Get:9 http://deb.debian.org/debian buster/main amd64 libkrb5support0 amd64 1.17-3+deb10u3 [65.8 kB]
Get:10 http://deb.debian.org/debian buster/main amd64 libk5crypto3 amd64 1.17-3+deb10u3 [122 kB]
Get:11 http://deb.debian.org/debian buster/main amd64 linux-image-4.19.0-18-amd64 amd64 4.19.208-1 [48.5 MB]
Get:12 http://deb.debian.org/debian buster/main amd64 linux-image-amd64 amd64 4.19+105+deb10u13 [8,316 B]
Get:13 http://deb.debian.org/debian buster/main amd64 psmisc amd64 23.2-1+deb10u1 [126 kB]
Get:14 http://deb.debian.org/debian buster/main amd64 shim-unsigned amd64 15.4-7~deb10u1 [429 kB]
Get:15 http://deb.debian.org/debian buster/main amd64 shim-helpers-amd64-signed amd64 1+15.4+7~deb10u1 [296 kB]
Get:16 http://deb.debian.org/debian buster/main amd64 shim-signed-common all 1.38~1+deb10u1+15.4-7~deb10u1 [13.7 kB]
Get:17 http://deb.debian.org/debian buster/main amd64 shim-signed amd64 1.38~1+deb10u1+15.4-7~deb10u1 [318 kB]
Fetched 51.1 MB in 5s (10.5 MB/s) 
Reading changelogs... Done
Preconfiguring packages ...
(Reading database ... 35263 files and directories currently installed.)
Preparing to unpack .../base-files_10.3+deb10u11_amd64.deb ...
Unpacking base-files (10.3+deb10u11) over (10.3+deb10u10) ...
Setting up base-files (10.3+deb10u11) ...
Installing new version of config file /etc/debian_version ...
(Reading database ... 35263 files and directories currently installed.)
Preparing to unpack .../debconf-i18n_1.5.71+deb10u1_all.deb ...
Unpacking debconf-i18n (1.5.71+deb10u1) over (1.5.71) ...
Found initrd image: /boot/initrd.img-4.19.0-16-amd64
Adding boot menu entry for EFI firmware configuration
done
Setting up psmisc (23.2-1+deb10u1) ...
Setting up distro-info-data (0.41+deb10u4) ...
Setting up python3-debconf (1.5.71+deb10u1) ...
Setting up debconf-i18n (1.5.71+deb10u1) ...
Setting up krb5-locales (1.17-3+deb10u3) ...
Setting up linux-image-amd64 (4.19+105+deb10u13) ...
Setting up libkrb5support0:amd64 (1.17-3+deb10u3) ...
Setting up tzdata (2021a-0+deb10u2) ...

Current default time zone: 'Asia/Kolkata'
Local time is now:      Wed Oct 13 08:21:50 IST 2021.
Universal Time is now:  Wed Oct 13 02:51:50 UTC 2021.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

Setting up shim-signed-common (1.38~1+deb10u1+15.4-7~deb10u1) ...
No DKMS packages installed: not changing Secure Boot validation state.
Setting up libk5crypto3:amd64 (1.17-3+deb10u3) ...
Setting up libkrb5-3:amd64 (1.17-3+deb10u3) ...
Setting up shim-unsigned (15.4-7~deb10u1) ...
Setting up libgssapi-krb5-2:amd64 (1.17-3+deb10u3) ...
Setting up shim-helpers-amd64-signed (1+15.4+7~deb10u1) ...
Installing for x86_64-efi platform.
Installation finished. No error reported.
Setting up shim-signed:amd64 (1.38~1+deb10u1+15.4-7~deb10u1) ...
Installing for x86_64-efi platform.
Installation finished. No error reported.
No DKMS packages installed: not changing Secure Boot validation state.
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10) ...

Yes, apt command provides a high-level commandline interface for the package management system.

1 Like

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki