Skip to content
Latchkey

npm Registry Errors in CI: ECONNRESET, ETIMEDOUT, and 5xx

npm install pulls from a shared registry over the network. Transient resets, timeouts, and 5xx responses are common in CI and almost always pass on retry.

What this error means

npm install/npm ci fails partway through fetching packages with a network error or a 4xx/5xx from the registry. Re-running the job usually succeeds with no change.

npm output
npm error code ECONNRESET
npm error network request to https://registry.npmjs.org/... failed,
reason: read ECONNRESET

Common causes

Transient network or registry instability

Brief connectivity blips or registry load cause resets, timeouts, and 503s. None reflect a problem with your project.

Rate limiting on shared CI IPs

Unauthenticated, high-volume installs from shared runner IPs can be throttled (429).

How to fix it

Add registry retries

npm has built-in fetch retry settings; raise them in CI.

Terminal
npm config set fetch-retries 5
npm config set fetch-retry-factor 2
npm config set fetch-retry-mintimeout 10000
npm ci

Cache and mirror

  1. Cache ~/.npm between runs so most installs are local.
  2. Use a registry proxy/mirror or your own private registry to reduce external calls.
  3. Authenticate to raise rate limits.

How to prevent it

  • Cache the npm download cache keyed on your lockfile.
  • Pin dependencies with a committed lockfile and npm ci.
  • Use a mirror for high-volume pipelines.

Related guides

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