Skip to content
Latchkey

apt-get update "Failed to fetch" from Mirror in CI

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

  1. Point apt at a fast, nearby mirror.
  2. Use a caching apt proxy for CI.
  3. 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →