npm ERR_SOCKET_TIMEOUT "Socket timeout" - Fix Stalled Registry Downloads in CI
By Daniel Zoghalchali·Latchkey
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 ci
Make downloads smaller and local
Cache ~/.npm so 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.
Frequently asked questions
What causes ""ERR_SOCKET_TIMEOUT""?
Congestion or a flaky link lets a large tarball stop streaming long enough to trip the idle socket timeout, so npm kills the request.
How do I fix "ERR_SOCKET_TIMEOUT"?
Give slow downloads more headroom and more attempts.
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.