CI "apt-get update: Failed to fetch ... Connection timed out"
apt-get update could not download a package index because the connection to the mirror timed out. It is a transient network/mirror issue - the same command usually succeeds on a re-run.
What this error means
apt-get update (or install) fails with Failed to fetch <url> ... Connection timed out, and often Some index files failed to download. A retry minutes later, or against a healthier mirror, completes.
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Could not connect to archive.ubuntu.com:80 ... Connection timed out
E: Failed to fetch http://archive.ubuntu.com/.../InRelease
E: Some index files failed to download.Common causes
A briefly slow or overloaded apt mirror
Distribution mirrors are shared infrastructure. Under load a mirror responds slowly or not at all, so the fetch exceeds apt’s timeout - nothing to do with your build.
Transient network congestion from the runner
A congested egress path or a momentary blip between the runner and the mirror makes the index download time out.
How to fix it
Enable apt retries and re-run
Tell apt to retry fetches automatically so a single blip is non-fatal.
apt-get -o Acquire::Retries=5 update
# persist:
echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/80-retriesUse a closer or pull-through mirror
- Point sources at a geographically closer mirror or an internal pull-through cache.
- Retry the whole step with backoff for transient timeouts.
- Cache the apt lists/packages between runs to reduce dependence on the mirror.
How to prevent it
- Set
Acquire::Retriesin CI so apt fetches retry by default. - Use an internal apt mirror or pull-through cache for high-volume pipelines.
- Cache downloaded packages to reduce mirror round trips.