npm Registry Errors in CI: ECONNRESET, ETIMEDOUT, and 5xx
By Kaveh Alemi·Latchkey
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.
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
Cache ~/.npm between runs so most installs are local.
Use a registry proxy/mirror or your own private registry to reduce external calls.
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.
Frequently asked questions
What causes "Registry ECONNRESET / 5xx"?
Brief connectivity blips or registry load cause resets, timeouts, and 503s. None reflect a problem with your project.
How do I fix Registry ECONNRESET / 5xx?
npm has built-in fetch retry settings; raise them in CI.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.