Skip to content
Latchkey

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 ci

Make downloads smaller and local

  1. Cache ~/.npm so large tarballs are not re-fetched each run.
  2. Use a closer/internal mirror to steady the byte stream.
  3. 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

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