npm ETIMEDOUT "network request … failed, reason: connect ETIMEDOUT" - Fix in CI
By Kaveh Alemi·Latchkey
ETIMEDOUT means npm opened (or tried to open) a connection to the registry and it never completed in time. DNS resolved fine, but the TCP connection or the download stalled.
What this error means
npm install/npm ci hangs while fetching, then fails with connect ETIMEDOUT or a request timeout for the registry. Re-running the job usually succeeds, the hallmark of a transient network stall.
A congested runner network or an overloaded registry/mirror means the connection cannot complete inside npm’s timeout window.
A proxy silently dropping connections
An egress proxy that blocks or throttles the registry can leave connections hanging until they time out rather than refusing them outright.
How to fix it
Raise the timeout and retries
Give npm more time and more attempts so a single stall self-recovers.
Terminal
npm config set fetch-retries 5
npm config set fetch-retry-maxtimeout 120000
npm config set fetch-timeout 120000
npm ci
Reduce dependence on the slow path
Cache ~/.npm so most packages are already local.
Point at a closer or internal mirror for high-volume pipelines.
Confirm the proxy allows and does not throttle the registry host.
How to prevent it
Set generous fetch-timeout and fetch-retries in CI.
Cache the npm download cache keyed on the lockfile.
Use a nearby mirror to cut connection latency.
Frequently asked questions
What causes ""npm error code ETIMEDOUT""?
A congested runner network or an overloaded registry/mirror means the connection cannot complete inside npm’s timeout window.
How do I fix "npm error code ETIMEDOUT"?
Give npm more time and more attempts so a single stall self-recovers.
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.