Skip to content
Latchkey

Bun "bun install" Failed in CI - Network & Registry Errors

bun install could not download packages. When it is a timeout or 5xx from the registry it is transient and clears on retry; when it is auth or a missing registry config it fails every time until fixed.

What this error means

bun install fails fetching a package - a connection reset, timeout, 5xx, or a 401/403 for a private package. Transient network errors pass on retry; auth/config errors do not.

bun output
error: Connection closed while downloading tarball for "react"
# or
error: GET https://registry.npmjs.org/@org%2fpkg - 401 Unauthorized

Common causes

Transient registry failure

A timeout, reset, or 5xx from the npm registry interrupts a download. These blips clear on their own and are unrelated to your manifest.

Missing registry config or auth token

A private scope without a configured registry/token returns 401/403. Bun needs a bunfig.toml (or .npmrc) with the registry and credentials.

How to fix it

Retry transient failures and cache installs

Retry on network flake; cache Bun’s install cache so most packages are already local.

Terminal
for i in 1 2 3; do bun install && break || sleep 10; done

Configure the registry and token for private packages

Set the scoped registry and an auth token (from a CI secret) so private packages authenticate.

bunfig.toml
# bunfig.toml
[install.scopes]
"@org" = { token = "$BUN_AUTH_TOKEN", url = "https://registry.npmjs.org/" }

How to prevent it

  • Cache Bun’s install cache keyed on bun.lockb.
  • Configure private registries/tokens in bunfig.toml via CI secrets.
  • Wrap installs in a retry for transient registry flake.

Related guides

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