cacheport

Error · Cargo

Fixing Cargo "spurious network error" warnings

Cargo hit a network error it considers temporary and is retrying. If all retries fail, the build stops with an error. The number in brackets is the underlying curl error; 28 means a timeout.

What you see

build log
warning: spurious network error (3 tries remaining): [28] Timeout was reached (Operation timed out after 30000 milliseconds with 0 bytes received)

Common causes

  • Slow or unstable links to static.crates.io.
  • Corporate proxies that Cargo is not configured for.
  • Many crates downloaded in parallel on a constrained connection.

How to fix it

  1. 01

    Retry more and wait longer

    Cargo reads network settings from its config.

    .cargo/config.toml
    [net]
    retry = 5
    
    [http]
    timeout = 120
  2. 02

    Configure a proxy

    If the runner is behind a proxy, set it for Cargo.

    .cargo/config.toml
    [http]
    proxy = "http://proxy.internal:3128"
  3. 03

    Replace crates.io with a regional cache

    Source replacement keeps Cargo.lock unchanged.

    .cargo/config.toml
    [registries.cacheport]
    index = "sparse+https://acme.cacheport.cc/cargo/index/"
    
    [source.crates-io]
    replace-with = "cacheport"

Other network failures in builds

Start on the free plan

20 GB of cache, every registry, unlimited users. Upgrade when your pipelines outgrow it.