Skip to content
Latchkey

Cargo "failed to update registry" / crates.io Index Failures

Cargo could not fetch or update the crates.io index. This is almost always a transient network failure reaching the index, not a problem with your manifest, and usually succeeds on retry.

What this error means

cargo fails early with failed to update registry crates-io`` and a network error - a spurious failure during the index fetch or download. Re-running the job typically works with no change, the hallmark of a transient issue.

cargo output
error: failed to get `serde` as a dependency of package `app v0.1.0`

Caused by:
  failed to update registry `crates-io`
Caused by:
  network failure seems to have happened ... timed out

Common causes

Transient network failure reaching the index

A brief connectivity blip or a slow response from the crates.io index (or its CDN) makes the fetch fail. Nothing is wrong with your project.

No cached registry on a cold runner

A fresh runner has no ~/.cargo/registry, so every build must fetch the full index over the network - more exposure to a flaky link.

How to fix it

Retry and use the sparse protocol

The sparse index fetches only what is needed and is far more robust than the old full-clone git index.

Terminal
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
export CARGO_NET_RETRY=5
cargo build --locked

Cache the cargo registry and git dirs

Caching ~/.cargo between runs means the index and downloaded crates are already local, so a flaky network matters far less.

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

How to prevent it

  • Use the sparse registry protocol (default since Rust 1.70) for resilient index fetches.
  • Cache ~/.cargo/registry and ~/.cargo/git keyed on Cargo.lock.
  • Set CARGO_NET_RETRY so transient fetches retry automatically.

Related guides

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