APT hash sum mismatch errors prevent package installation and updates on Debian/Ubuntu systems. The error indicates that downloaded package metadata doesn't match expected checksums, which can be caused by mirror synchronization issues, corrupted caches, or network problems.
Understanding the Error
# Typical error message:
# W: Failed to fetch http://archive.ubuntu.com/...Packages
# Hash Sum mismatch
# Hashes of expected file:
# - SHA256:abc123...
# Hashes of received file:
# - SHA256:def456...
Fix 1: Clean and Retry
# Clear APT cache and package lists
sudo rm -rf /var/lib/apt/lists/*
sudo apt clean
sudo apt update
# If the error persists, use a different mirror
Fix 2: Switch Mirrors
# Use a different mirror
sudo sed -i 's|http://archive.ubuntu.com|http://us.archive.ubuntu.com|g' /etc/apt/sources.list
sudo apt update
# Or use a known-good mirror
sudo sed -i 's|http://archive.ubuntu.com|http://mirrors.edge.kernel.org/ubuntu|g' /etc/apt/sources.list
sudo apt update
Fix 3: Proxy/CDN Issues
# If behind a caching proxy, it might serve stale data
# Bypass proxy temporarily
sudo apt -o Acquire::http::Proxy="DIRECT" update
# Disable HTTP pipelining (fixes some proxy issues)
echo 'Acquire::http::Pipeline-Depth "0";' | sudo tee /etc/apt/apt.conf.d/99pipeline
sudo apt update
# Force IPv4 (some proxies break IPv6)
echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4
sudo apt update
Fix 4: Corrupt Local Files
# Remove potentially corrupted partial downloads
sudo rm -rf /var/lib/apt/lists/partial/*
sudo rm -rf /var/cache/apt/archives/partial/*
# Reset APT completely
sudo rm -rf /var/lib/apt/lists/*
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt clean
sudo apt update
Fix 5: Third-Party Repository Issues
# Third-party repos are more likely to have hash issues
# Identify which repo is failing from the error URL
# Temporarily disable it
sudo mv /etc/apt/sources.list.d/problematic.list /etc/apt/sources.list.d/problematic.list.disabled
sudo apt update
# Re-add with the correct key
sudo rm /etc/apt/sources.list.d/problematic.list.disabled
# Follow the repository's official installation instructions
Fix 6: Release File Changes
# If you get "repository changed its 'Label'" or similar
sudo apt update --allow-releaseinfo-change
Best Practices
- Start with
rm -rf /var/lib/apt/lists/*andapt update— fixes most cases - Try a different mirror if the issue persists — mirror sync delays are common
- Check for proxy interference — caching proxies are a frequent cause
- Wait and retry: Mirror synchronization usually completes within a few hours
- Use HTTPS sources to prevent network-level tampering