Linux & OS Intermediate

Resolving Ubuntu apt-get update ‘Hash Sum mismatch’ Errors on Ubuntu 20.04 LTS

Troubleshoot and fix 'Hash Sum mismatch' errors during `apt-get update` on Ubuntu 20.04 LTS, often caused by repository caching issues or network inconsistencies.

👨‍💻
Senior Systems Architect • Verified in Staging Labs

Troubleshoot and fix 'Hash Sum mismatch' errors during `apt-get update` on Ubuntu 20.04 LTS, often caused by repository caching issues or network inconsistencies.

As an experienced Systems Administrator and DevOps engineer, encountering Hash Sum mismatch errors during apt-get update operations on your Ubuntu servers can be frustrating. This error prevents your system from correctly updating its package lists, potentially leading to outdated software, security vulnerabilities, and failed package installations. While seemingly complex, this issue is usually rooted in inconsistent package data due to network caching, corrupted local files, or repository synchronization problems. This guide will walk you through diagnosing and resolving this common issue on Ubuntu 20.04 LTS (Focal Fossa).

Symptom & Error Signature

When you run sudo apt-get update (or sudo apt update), instead of a clean refresh of package lists, you might see output similar to this:

root@webserver:~# sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Err:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Hash Sum mismatch
Hashes of expected file:
 - Filesize: 114060 [weak]
 - MD5Sum: 301646270b2ae147171e06d9a9244ee9
 - SHA1: 3422037920409a473b987b2827a5f60b8d7890f6
 - SHA256: 3c6258c70d44093f15f9e160e3344197e937d391054ee45e7f62e8489a71a179
 - SHA512: 5937a502f90a5f33519d53c3014882194519f72b64d1c37b98544c9b1390977e90c8e31a0e1c3132d431057c3905e3f140654e95085e68344e271295325501fb
Last-Update: Sat, 06 Nov 2026 12:34:56 GMT
Ign:4 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Err:5 http://ppa.launchpad.net/ondrej/php/ubuntu focal Release
  Could not download hashsum from the description file (file has unexpected size (71330 != 71329). Should be 71329):
  [IP: 185.125.190.80 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Hash Sum mismatch
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/focal/Release  Could not download hashsum from the description file (file has unexpected size (71330 != 71329). Should be 71329):
E: Some index files failed to download. They have been ignored, or old ones used instead.

The key indicators are the lines mentioning Hash Sum mismatch or Could not download hashsum from the description file (file has unexpected size...) followed by E: Failed to fetch....

Root Cause Analysis

The Hash Sum mismatch error occurs when the cryptographic hash (like MD5, SHA1, SHA256) of a downloaded package index file (e.g., InRelease, Packages.gz) does not match the hash recorded in its corresponding Release file or metadata. This integrity check is crucial for security, ensuring that package lists haven't been tampered with or corrupted.

The primary reasons for this discrepancy typically fall into these categories:

  1. Network Caching/Proxy Issues: This is the most common cause.

    • ISP-level or Corporate Proxies: Intermediary proxy servers (e.g., transparent proxies, caching proxies) might serve an outdated or partially cached version of a repository index file, leading to a mismatch with the actual Release file's expected hash.
    • Content Delivery Networks (CDNs): Repository mirrors often use CDNs. Occasionally, a CDN node might not be perfectly synchronized, delivering an inconsistent file.
    • Incomplete Downloads: Network interruptions or flaky connections can result in partial downloads of index files, which then fail the hash verification.
  2. Corrupted Local apt Cache: Your local apt cache, located in /var/lib/apt/lists/, stores downloaded package index files. If these files become corrupted due to disk errors, unexpected power loss, or bugs, subsequent apt update operations will fail hash checks.

  3. Repository Synchronization Problems: Less common with official Ubuntu mirrors, but possible with third-party PPAs or custom repositories. The repository itself might be experiencing synchronization issues, where the Release file is updated before all the underlying package index files are consistent across all mirror nodes.

  4. Incorrect System Time: While less directly tied to Hash Sum mismatch than other apt errors (e.g., GPG signature validation issues), a significant system time skew can sometimes indirectly cause problems with repository metadata freshness validation, leading to perceived inconsistencies.

  5. Insufficient Disk Space: If your / or /var partition is critically low on disk space, apt might fail to fully download index files, leading to partial and thus corrupted files that trigger the hash mismatch.

Step-by-Step Resolution

Follow these steps in order, testing sudo apt-get update after each significant change.

1. Clear the Local apt Cache and Old Lists

This is the most common and effective solution, forcing apt to redownload all package lists from scratch.

  1. Remove existing package lists:

    sudo rm -rf /var/lib/apt/lists/*
    

    The rm -rf command is powerful. Ensure you type it precisely as shown. It recursively deletes files and directories without confirmation.

  2. Clean up downloaded .deb packages (optional but good practice):

    sudo apt-get clean
    
  3. Attempt to update package lists again:

    sudo apt-get update
    

    If the error persists, proceed to the next step.

2. Change Repository Mirrors

If clearing the cache doesn't work, your current mirror might be serving inconsistent data, or an upstream network proxy is interfering. Changing to a different, reliable mirror can often bypass this.

  1. Backup your current sources.list file:

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    
  2. Edit sources.list to use a different mirror: You can either manually edit the file using nano or vim, or use sed for a quick change. We'll use a sed example to switch from archive.ubuntu.com to mirrors.kernel.org (a common, reliable mirror). Adapt the mirror URL to one geographically closer or known to be reliable for you.

    sudo sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.kernel.org/ubuntu|g' /etc/apt/sources.list
    sudo sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.kernel.org/ubuntu|g' /etc/apt/sources.list
    

    If you're using other specific mirrors (e.g., a corporate mirror or a CDN like azure.archive.ubuntu.com), you might need to adjust the sed command or manually edit the file. For specific regional mirrors, consider options like us.archive.ubuntu.com, eu.archive.ubuntu.com, etc.

  3. Clear the local apt cache again (to ensure new mirror data is fetched):

    sudo rm -rf /var/lib/apt/lists/*
    
  4. Attempt to update package lists again:

    sudo apt-get update
    

3. Disable apt Proxy Configuration (if applicable)

If your server is behind a proxy, it might be interfering with apt downloads. Temporarily disabling the proxy can help diagnose the issue.

  1. Check for apt proxy settings: Look for files in /etc/apt/apt.conf.d/ that might configure proxies (e.g., 01proxy, 99proxy).

    grep -r "Proxy" /etc/apt/apt.conf.d/
    

    Also, check environment variables:

    echo $http_proxy $https_proxy
    
  2. Temporarily disable proxy settings:

    • For apt.conf.d files: Comment out (add # at the beginning of the line) any Acquire::http::Proxy or Acquire::https::Proxy directives in the relevant files.
      # Example for /etc/apt/apt.conf.d/01proxy
      # Acquire::http::Proxy "http://proxy.example.com:8080/";
      
    • For environment variables: Unset them for the current session.
      unset http_proxy
      unset https_proxy
      
  3. Clear the local apt cache and update:

    sudo rm -rf /var/lib/apt/lists/*
    sudo apt-get update
    

    If this resolves the issue, your proxy server is likely the culprit. You'll need to investigate its configuration or bypass it for apt updates.

4. Force IPv4 for apt (Diagnostic Step)

In rare cases, IPv6 network issues (e.g., faulty routing or transparent proxies mishandling IPv6 traffic) can lead to download problems. Forcing apt to use IPv4 can act as a diagnostic step.

  1. Run apt-get update with forced IPv4:
    sudo apt-get -o Acquire::ForceIPv4=true update
    
    If this resolves the issue, you might have an underlying IPv6 network configuration problem. This is a temporary workaround, and a proper fix would involve addressing the network's IPv6 setup.

5. Verify System Time Synchronization

An incorrect system clock can sometimes cause issues with package list validation, though it's more commonly associated with GPG signature errors.

  1. Check system time status:

    timedatectl status
    

    Ensure "NTP service: active" and "System clock synchronized: yes". The local time should also be accurate.

  2. Enable NTP synchronization if disabled:

    sudo timedatectl set-ntp true
    sudo systemctl restart systemd-timesyncd # or ntp if you use an alternative service
    

    If your system time is significantly off (e.g., years in the past or future), correct it manually first if NTP fails, then restart NTP. Incorrect time can affect many system processes, including SSL certificate validation.

  3. Clear apt cache and update:

    sudo rm -rf /var/lib/apt/lists/*
    sudo apt-get update
    

6. Check Disk Space

While not a direct cause of "Hash Sum mismatch," insufficient disk space can lead to incomplete downloads, which then manifest as hash mismatches.

  1. Check disk usage:

    df -h
    

    Pay attention to the / (root) and /var partitions, as /var/lib/apt/lists/ resides on the root filesystem and /var/cache/apt/archives/ on /var.

  2. Free up disk space if necessary:

    • Remove old log files.
    • Uninstall unused packages (sudo apt autoremove).
    • Clear apt archives (sudo apt-get clean).
    • Check for large Docker images or volumes (sudo docker system prune).
    • Identify large files or directories using du -sh /* or du -sh /var/*.

By systematically working through these troubleshooting steps, you should be able to identify and resolve the Hash Sum mismatch error on your Ubuntu 20.04 LTS system, restoring full functionality to your apt package manager.

👨‍💻

Johnathon Wheeler

Senior Systems Architect & DevOps Engineer • Austin, TX

Connect on LinkedIn →

Johnathon has over 16 years of hands-on experience designing, debugging, and scaling Linux web hosting stacks, container clusters, and high-availability database architectures. Every guide on ButItWorkedLocal is independently tested against Debian 12, Ubuntu 24.04/22.04 LTS, Rocky Linux, and Docker environments to guarantee reproducibility in production.

🛡️

Our Production Verification Guarantee

Encountering a bug not covered here or running a non-standard kernel configuration? Our solutions are continually refined against real production incidents. Submit an environment trace for our editorial team to replicate.