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.
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:
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
Releasefile'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.
- 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
Corrupted Local
aptCache: Your localaptcache, 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, subsequentapt updateoperations will fail hash checks.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
Releasefile is updated before all the underlying package index files are consistent across all mirror nodes.Incorrect System Time: While less directly tied to
Hash Sum mismatchthan otherapterrors (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.Insufficient Disk Space: If your
/or/varpartition is critically low on disk space,aptmight 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.
Remove existing package lists:
sudo rm -rf /var/lib/apt/lists/*The
rm -rfcommand is powerful. Ensure you type it precisely as shown. It recursively deletes files and directories without confirmation.Clean up downloaded
.debpackages (optional but good practice):sudo apt-get cleanAttempt to update package lists again:
sudo apt-get updateIf 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.
Backup your current
sources.listfile:sudo cp /etc/apt/sources.list /etc/apt/sources.list.backupEdit
sources.listto use a different mirror: You can either manually edit the file usingnanoorvim, or usesedfor a quick change. We'll use asedexample to switch fromarchive.ubuntu.comtomirrors.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.listIf you're using other specific mirrors (e.g., a corporate mirror or a CDN like
azure.archive.ubuntu.com), you might need to adjust thesedcommand or manually edit the file. For specific regional mirrors, consider options likeus.archive.ubuntu.com,eu.archive.ubuntu.com, etc.Clear the local
aptcache again (to ensure new mirror data is fetched):sudo rm -rf /var/lib/apt/lists/*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.
Check for
aptproxy 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_proxyTemporarily disable proxy settings:
- For apt.conf.d files: Comment out (add
#at the beginning of the line) anyAcquire::http::ProxyorAcquire::https::Proxydirectives 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
- For apt.conf.d files: Comment out (add
Clear the local
aptcache and update:sudo rm -rf /var/lib/apt/lists/* sudo apt-get updateIf this resolves the issue, your proxy server is likely the culprit. You'll need to investigate its configuration or bypass it for
aptupdates.
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.
- Run
apt-get updatewith forced IPv4:
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.sudo apt-get -o Acquire::ForceIPv4=true update
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.
Check system time status:
timedatectl statusEnsure "NTP service: active" and "System clock synchronized: yes". The local time should also be accurate.
Enable NTP synchronization if disabled:
sudo timedatectl set-ntp true sudo systemctl restart systemd-timesyncd # or ntp if you use an alternative serviceIf 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.
Clear
aptcache 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.
Check disk usage:
df -hPay attention to the
/(root) and/varpartitions, as/var/lib/apt/lists/resides on the root filesystem and/var/cache/apt/archives/on/var.Free up disk space if necessary:
- Remove old log files.
- Uninstall unused packages (
sudo apt autoremove). - Clear
aptarchives (sudo apt-get clean). - Check for large Docker images or volumes (
sudo docker system prune). - Identify large files or directories using
du -sh /*ordu -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.
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.