How to Fix ‘Hash Sum mismatch’ apt Error in Ubuntu

Running sudo apt update or installing packages on Ubuntu or Debian only to be halted by the error: E: Failed to fetch http://archive.ubuntu.com/ubuntu/... Hash Sum mismatch and E: Some index files failed to download. They have been ignored, or old ones used instead stops software upgrades. In Debian package management architecture, APT enforces rigorous cryptographic integrity checks: every repository releases a Release or InRelease manifest containing SHA-256 and MD5 cryptographic hashes for every package list. When the hash calculated from the downloaded file differs from the hash declared in the repository manifest, APT abruptly terminates the transaction to protect the system against corrupted downloads, partial transfers, or hostile man-in-the-middle package tampering. This guide covers how to resolve Hash Sum mismatch errors in Ubuntu.

What Causes “Hash Sum Mismatch” in Ubuntu APT?

Cryptographic hash mismatches typically stem from transparent network proxies, out-of-sync mirror servers, and corrupted local caches:

  • Out-of-Sync Repository Mirrors: During mirror synchronisation (which occurs multiple times daily), a local mirror server updates its InRelease index file before all individual binary package lists finish uploading, creating a temporary hash discrepancy.
  • Caching Transparent Web Proxies: ISPs, university networks, corporate proxies, or local caching daemons (like squid or apt-cacher-ng) caching stale versions of repository index files and serving them alongside newer package releases.
  • Corrupted Local APT Package Lists: Fragmented or partially downloaded index files residing in /var/lib/apt/lists/partial/.
  • Network Packet Truncation: Flaky Wi-Fi connections, aggressive MTU packet fragmentation, or faulty network interface cards corrupting data bytes during HTTP download streaming.

Method 1: Purge Corrupted Local Package Lists and Re-synchronise

Deleting cached repository index files forces APT to download a pristine, complete set of manifests from source servers.

  1. Open your terminal.
  2. Clean the local package cache:
    sudo apt clean
  3. Delete all cached repository metadata files:
    sudo rm -rf /var/lib/apt/lists/*
  4. Recreate the partial staging directory:
    sudo mkdir -p /var/lib/apt/lists/partial
  5. Run a fresh update:
    sudo apt update

Method 2: Bypass Transparent Caching Proxies via APT Configuration

If your ISP or enterprise firewall caches web traffic, instruct APT to bypass HTTP proxy caches using custom header flags.

  1. Create a new APT configuration file:
    sudo nano /etc/apt/apt.conf.d/99no-cache
  2. Add the following directives to disable caching and enforce direct server connections:
    Acquire::http::No-Cache "true";
    Acquire::http::Pipeline-Depth "0";
    Acquire::https::No-Cache "true";
    Acquire::https::Pipeline-Depth "0";
  3. Save and exit (Ctrl + O, then Ctrl + X).
  4. Purge list caches and re-run update:
    sudo rm -rf /var/lib/apt/lists/* && sudo apt update

Method 3: Switch to Official Main Ubuntu Archive Mirrors

Regional country mirrors (such as us.archive.ubuntu.com or in.archive.ubuntu.com) experience sync delays. Switching to the authoritative primary archive resolves index mismatches.

  1. Back up your existing sources list:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  2. Open /etc/apt/sources.list in a text editor:
    sudo nano /etc/apt/sources.list
  3. Replace regional prefixes (e.g. http://us.archive.ubuntu.com/ubuntu/) with the main archive mirror:
    http://archive.ubuntu.com/ubuntu/
  4. Save the file and run sudo apt update.

Method 4: Fix MTU Packet Fragmentation and MTU Clamping

If Hash Sum mismatch errors occur on specific routers or VPN tunnels, lowering the Maximum Transmission Unit (MTU) prevents packet loss.

  1. Check your current MTU size:
    ip link show
  2. If MTU is set to 1500, temporarily lower it to 1400 on your active interface (e.g. eth0 or wlan0):
    sudo ip link set dev eth0 mtu 1400
  3. Re-run sudo apt update. If it succeeds, configure your router’s MSS clamping or set the permanent MTU in Netplan.

APT Hash Sum Mismatch Troubleshooting Matrix

Failure Pattern Underlying Cause Primary Resolution
Hash Sum mismatch on all repositories ISP transparent caching proxy serving mixed old/new files Add Acquire::http::No-Cache "true"; in apt.conf.d
Hash Sum mismatch on country-code mirror only Regional mirror in mid-sync synchronization gap Switch sources.list to main archive.ubuntu.com mirror
Hash mismatch on specific third-party PPA PPA package rebuilt without updated Release signature Wait 1 hour for PPA sync or remove PPA via add-apt-repository
Error repeats after deleting /var/lib/apt/lists/ Network packet corruption over Wi-Fi / VPN MTU Lower interface MTU to 1400; test via wired Ethernet

Frequently Asked Questions

Is Hash Sum Mismatch caused by a virus or security attack?

While the cryptographic check exists to detect unauthorized file modifications, 99.9% of Hash Sum Mismatch errors are benign network artifacts caused by asynchronous mirror synchronization or ISP proxy caching. However, APT’s refusal to install the mismatched files ensures your system is never compromised by damaged packages.

Can I force APT to ignore Hash Sum Mismatch?

No, and you should not attempt to do so. Unlike unsigned repository warnings, APT hard-codes cryptographic checksum validation because installing a corrupted binary archive will corrupt package dependencies and render Linux unbootable.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.