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))
doneUse 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 updatein 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
CI 503/502 from a Package RegistryFix 503 / 502 from a package registry in CI, a transient upstream error. How to retry and why a 5xx self-heal…
CI "Connection timed out" (ETIMEDOUT) DownloadingFix "Connection timed out" / ETIMEDOUT in CI while downloading deps, a transient network stall. How to retry…
CI "Temporary failure in name resolution" (EAI_AGAIN)Fix "Temporary failure in name resolution" (EAI_AGAIN) in CI, a transient DNS resolver failure. How to retry…
apt-get: "No space left on device" Installing PackagesFix "No space left on device" during apt-get in CI when the package cache and unpacked files fill the disk. H…