This error occurs when apt-get cannot download packages from your configured repositories due to network issues, outdated package lists, or missing/broken packages. It typically indicates that some packages failed to fetch during installation and you need to retry or fix broken dependencies.
The "Unable to fetch some archives" error in apt means that the package manager encountered one or more packages it couldn't download from the configured software repositories. This can happen for several reasons: - Your local package list is out of sync with the repository (missing or broken package references) - Network connectivity issues preventing downloads from repository mirrors - Repository URLs are incorrect, outdated, or the servers are temporarily unavailable - Previous installation attempts were interrupted, leaving your package system in a partially broken state - The package you're trying to install has unmet dependencies that cannot be fetched The error message suggests two solutions: running `apt-get update` to refresh the package list, or using `--fix-missing` to attempt installation despite fetch failures.
The first and most important step is to update your local package list to sync with the repositories.
sudo apt-get updateThis command refreshes the package index files from all configured repositories. It may show:
- "404 Not Found" errors for packages no longer available (safe to ignore)
- "Suite value changed" warnings (you may need to accept the change)
If you see 'Suite value changed' warnings:
# The system is asking you to acknowledge that a repository has changed
# This is normal during system upgrades (e.g., from 20.04 to 22.04)
# The system will automatically handle it on the next update
sudo apt-get updateAfter this completes, try your original operation:
sudo apt-get install package-nameIf apt-get update didn't fully resolve the issue, use the --fix-missing flag to attempt installation while skipping packages that cannot be fetched.
sudo apt-get install --fix-missingOr for a specific package:
sudo apt-get install --fix-missing package-nameWhat --fix-missing does:
- Continues installation despite failed downloads
- Skips packages that cannot be fetched
- Allows other dependencies to be satisfied
- Leaves your system in a consistent state
Note: --fix-missing should be used after apt-get update. Using it without updating first may leave unmet dependencies.
If the above steps don't work, clean your package cache and retry.
# Clean package cache
sudo apt-get clean
# Update package lists again
sudo apt-get update
# Try the installation again
sudo apt-get install package-nameWhat apt-get clean does:
- Removes all packages from the local download directory (/var/cache/apt/archives/)
- Frees up disk space
- Forces apt to re-download fresh copies of packages
Alternative: Use autoclean for partial cleanup
# Keep newer package versions, remove older cached versions
sudo apt-get autoclean
# Update and retry
sudo apt-get update
sudo apt-get install package-nameIf you have broken dependencies preventing installations, use apt-get install -f (or apt --fix-broken).
# Fix broken packages
sudo apt-get install -fThis command:
- Scans your system for broken package dependencies
- Attempts to resolve them by installing missing packages
- May remove conflicting packages if necessary
If you see unmet dependencies:
# Check for held or conflicting packages
sudo apt-mark showhold
# See detailed dependency issues
sudo apt-get checkCheck that your repositories are correctly configured.
# View your configured repositories
cat /etc/apt/sources.list
# Also check additional repository files
ls -la /etc/apt/sources.list.d/Common issues:
- PPA repositories that are no longer maintained
- Repository URLs using outdated domain names
- Disabled repositories in sources.list.d/ files
On Ubuntu, restore default repositories:
# Backup current sources
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# Restore Ubuntu default repositories (requires knowing your release)
# First, find your Ubuntu release name
lsb_release -cs
# Then restore defaults (example for jammy/22.04)
# This varies by version - check Ubuntu documentationCheck for disabled PPAs:
# List all PPAs (Personal Package Archives)
sudo apt-cache policy
# Remove problematic PPAs
sudo add-apt-repository --remove ppa:user/ppa-nameInsufficient disk space can cause download failures.
# Check available disk space
df -h
# Check space in /var partition (where packages are cached)
df -h /varIf disk space is low:
# Clean package cache
sudo apt-get clean
# Remove old package versions
sudo apt-get autoclean
# Remove unused dependencies
sudo apt-get autoremoveIf still low on space:
# Find large files/directories
sudo du -sh /var/cache/*
sudo du -sh /var/log/*
# Clean old logs if necessary
sudo journalctl --vacuum=50MIf your current repository mirror is slow or offline, switch to a different mirror.
On Ubuntu, edit sources.list:
sudo nano /etc/apt/sources.listReplace the mirror URL (example changing archive.ubuntu.com to a different mirror):
# Original
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted
# Change to a different mirror (e.g., Ubuntu's mirror)
deb http://security.ubuntu.com/ubuntu/ jammy main restrictedCommon Ubuntu mirrors:
- http://archive.ubuntu.com/ - Main archive
- http://security.ubuntu.com/ - Security updates
- http://br.archive.ubuntu.com/ - Brazil mirror
- http://mirror.example.com/ - Various regional mirrors
On Debian, use the official repository:
# Debian sources.list example
deb http://deb.debian.org/debian bookworm main
deb http://deb.debian.org/debian-security bookworm-security mainAfter editing, update and retry:
sudo apt-get update
sudo apt-get install package-nameTest your connection to repository servers.
# Test connectivity to Ubuntu archive
curl -I http://archive.ubuntu.com
# Test connectivity to Debian repository
curl -I http://deb.debian.org
# Test DNS resolution
nslookup archive.ubuntu.comIf behind a proxy or firewall:
# Configure apt to use a proxy
sudo nano /etc/apt/apt.conf.d/proxy.conf
# Add these lines (replace proxy-server:8080 with your proxy)
Acquire::http::Proxy "http://proxy-server:8080/";
Acquire::https::Proxy "http://proxy-server:8080/";Test with curl using proxy:
curl -x http://proxy-server:8080 -I http://archive.ubuntu.comAfter verifying connectivity:
sudo apt-get update
sudo apt-get install package-name### Understanding Package Fetch Failures
When apt reports "Unable to fetch some archives," it means one or more package files couldn't be downloaded. This is different from dependency resolution errors.
Common scenarios:
1. Partial failure with --fix-missing recovery:
Some packages fail to fetch, but core dependencies are available. Using --fix-missing allows the installation to proceed with available packages.
2. Repository suite changes (Ubuntu releases):
When upgrading from one Ubuntu version to another (e.g., 20.04 to 22.04), repositories change their "Suite" designation from "focal" to "jammy". This requires explicit acknowledgment.
3. Mirror synchronization lag:
Repository mirrors don't sync instantaneously. If you see "404 Not Found" for newly released packages, waiting a few minutes before retrying often resolves the issue.
4. Docker/Container context:
This error is especially common in Dockerfiles because:
- The base image's package mirror may be slow or unreliable
- Build environments may have network restrictions
- Multiple build steps retrying the same operations
For Dockerfiles, the recommended fix is:
RUN apt-get update && \
apt-get install -y --no-install-recommends \
package1 \
package2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*### Best Practices
Always update before installing:
sudo apt-get update && sudo apt-get install package-nameUse apt instead of apt-get (on newer systems):
# Modern alternative (Ubuntu 18.04+)
sudo apt update
sudo apt install package-nameKeep your system clean:
# Regular maintenance
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get autocleanFor reliable production deploys:
- Pin specific package versions to avoid unexpected changes
- Maintain a local mirror of critical packages
- Test updates in a staging environment first
- Document your repository configuration in version control
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT