Skip to content
Latchkey

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.

CI log
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.

Terminal
apt-get -o Acquire::Retries=5 update
# persist:
echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/80-retries

Use a closer or pull-through mirror

  1. Point sources at a geographically closer mirror or an internal pull-through cache.
  2. Retry the whole step with backoff for transient timeouts.
  3. Cache the apt lists/packages between runs to reduce dependence on the mirror.

How to prevent it

  • Set Acquire::Retries in 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.

Frequently asked questions

What causes ""apt: Failed to fetch ... Connection timed out""?
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.
How do I fix "apt: Failed to fetch ... Connection timed out"?
Tell apt to retry fetches automatically so a single blip is non-fatal.
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.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card