Skip to content
Latchkey

cargo "429 Too Many Requests" from crates.io in CI

crates.io returned HTTP 429, meaning the runner sent more requests than the registry allows in a window. This is a transient rate limit, common from shared CI egress IPs, not a problem with your dependencies.

What this error means

cargo fetch or build fails with "error: failed to download from ..." and a "429 Too Many Requests" status while downloading crates or updating the index.

cargo
error: failed to download from `https://static.crates.io/crates/serde/serde-1.0.203.crate`
Caused by:
  failed to get successful HTTP response from `https://static.crates.io/...`, got 429
  body:
  Too Many Requests

Common causes

Shared CI egress IP hit the rate limit

Many jobs from the same hosted-runner IP range share a quota, so a burst of downloads can trip the limit even for a small project.

No caching, so every run re-downloads everything

Without a crate cache, each job fetches the full dependency set, multiplying requests and the chance of a 429.

How to fix it

Cache the cargo registry and retry

Persist the registry and git caches so most crates are already present and only deltas are fetched.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: |
      ~/.cargo/registry
      ~/.cargo/git
    key: cargo-${{ hashFiles('Cargo.lock') }}

Use a sparse index and back off on retry

The sparse protocol fetches only needed index files; re-running the job after a short wait usually clears a transient 429.

Terminal
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo fetch --locked

How to prevent it

  • Cache ~/.cargo/registry and ~/.cargo/git across runs.
  • Use the sparse index to cut request volume.
  • Pin Cargo.lock so only required crates are fetched.

Frequently asked questions

What causes ""429 Too Many Requests""?
Many jobs from the same hosted-runner IP range share a quota, so a burst of downloads can trip the limit even for a small project.
How do I fix "429 Too Many Requests"?
Persist the registry and git caches so most crates are already present and only deltas are fetched.

Related guides

References

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