npm ERR_SOCKET_TIMEOUT "Socket timeout" - Fix Stalled Registry Downloads in CI
ERR_SOCKET_TIMEOUT means an established connection went idle for longer than npm’s socket timeout and was torn down mid-transfer. The link was up but stopped delivering bytes.
What this error means
A download stalls partway and npm aborts with ERR_SOCKET_TIMEOUT or "Socket timeout". It is intermittent and usually clears on retry, especially for large tarballs over a congested link.
npm output
npm error code ERR_SOCKET_TIMEOUT
npm error network request to https://registry.npmjs.org/.../big-pkg.tgz failed,
reason: Socket timeout
npm error network This is a problem related to network connectivity.Common causes
A connection stalled mid-download
Congestion or a flaky link lets a large tarball stop streaming long enough to trip the idle socket timeout, so npm kills the request.
A slow proxy or mirror under load
An overloaded proxy/mirror can pause the byte stream past the timeout window, especially for big binary packages.
How to fix it
Raise the socket timeout and retries
Give slow downloads more headroom and more attempts.
Terminal
npm config set fetch-timeout 300000
npm config set fetch-retries 5
npm config set fetch-retry-maxtimeout 120000
npm ciMake downloads smaller and local
- Cache
~/.npmso large tarballs are not re-fetched each run. - Use a closer/internal mirror to steady the byte stream.
- Re-run the job - an idle-socket timeout is usually transient.
How to prevent it
- Set a generous fetch-timeout for pipelines pulling large packages.
- Cache the npm download cache keyed on the lockfile.
- Prefer a reliable, nearby mirror.
Related guides
npm ETIMEDOUT "network request … failed, reason: connect ETIMEDOUT" - Fix in CIFix npm ETIMEDOUT "connect ETIMEDOUT" in CI - a connection to the registry that timed out, usually a transien…
npm EAI_AGAIN "getaddrinfo EAI_AGAIN" - Fix Temporary DNS Failure in CIFix npm EAI_AGAIN "getaddrinfo EAI_AGAIN registry.npmjs.org" in CI - a temporary DNS failure, common inside D…
npm ENOTFOUND "request to … failed, reason: getaddrinfo ENOTFOUND" - Fix in CIFix npm ENOTFOUND "getaddrinfo ENOTFOUND registry.npmjs.org" in CI - a DNS resolution failure reaching the re…