apt-get update "Failed to fetch" from Mirror in CI
By Daniel Zoghalchali·Latchkey
apt could not download index or package files from a mirror. In CI this is usually a transient mirror outage or network blip, not a broken sources list.
What this error means
apt-get update or install prints Failed to fetch ... with a connection or 5xx error against a mirror. Re-running the unchanged job usually succeeds once the mirror recovers.
shell
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease Connection timed out
E: Some index files failed to download.
Common causes
A mirror was briefly unreachable
The configured mirror had a transient outage or network blip during the fetch.
Network stall to the mirror
Momentary congestion or packet loss broke the download mid-flight.
How to fix it
Retry the update
A short retry loop rides out a transient mirror blip.
shell
for i in 1 2 3; do
sudo apt-get update && break
sleep $((i*5))
done
Use a more reliable mirror
Point apt at a fast, nearby mirror.
Use a caching apt proxy for CI.
Pin package versions to reduce index churn.
How to prevent it
Retry apt-get update in CI.
Use a caching apt proxy/mirror.
On managed runners, transient mirror fetch failures are detected and the job is automatically retried, so a one-off blip does not fail the build.
Frequently asked questions
What causes "apt Failed to fetch"?
The configured mirror had a transient outage or network blip during the fetch.
How do I fix apt Failed to fetch?
A short retry loop rides out a transient mirror blip.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.