How to fix npm ERR! ESOCKETTIMEDOUT in npm

npmBEGINNERMEDIUMUpdated Dec 6, 2025ยท 246 views

The ESOCKETTIMEDOUT error occurs when npm cannot establish or maintain a network connection to the registry within the expected time. This typically indicates network issues, slow connections, or registry unavailability.

Quick fix

Fixes npm ERR! ESOCKETTIMEDOUT

npm config set fetch-timeout 300000
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
  1. Increase npm timeout settings
  2. Test registry connectivity
  3. Try a different registry mirror
  4. Check proxy and VPN settings
npm โ€” error
npm config set fetch-timeout 300000
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
npm ERR! ESOCKETTIMEDOUT

What this error means

ESOCKETTIMEDOUT means npm's network socket connection timed out while trying to communicate with the npm registry or another remote server. Unlike ETIMEDOUT which occurs during connection establishment, ESOCKETTIMEDOUT typically happens when a connection was established but the data transfer took too long. This error indicates that while npm was able to start a connection, the remote server stopped responding during the data exchange, or the network became too slow to complete the transfer within the allowed timeout period.

Typical symptoms

  • npm install hangs for a long time before failing
  • Error appears after partial package downloads
  • Intermittent failures on large package installations
  • CI/CD pipelines timeout during npm install
  • Problem worsens with slower network connections
  • Multiple retry attempts eventually succeed

Common causes

  1. Slow or unstable network connection
  2. npm registry server experiencing high load
  3. Corporate proxy or firewall throttling connections
  4. Large packages taking too long to download
  5. VPN connection causing latency issues
  6. DNS resolution delays
  7. ISP network congestion

How to fix "npm ERR! ESOCKETTIMEDOUT"

1Increase npm timeout settings

Extend the default timeout to allow more time for slow connections:

bash
npm config set fetch-timeout 300000
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
2Test registry connectivity

Check if you can reach the npm registry:

bash
npm ping
curl -I https://registry.npmjs.org

If these fail, the issue is network-related.

3Try a different registry mirror

Use an alternative registry or mirror closer to your location:

bash
# Use a mirror temporarily
npm install --registry https://registry.npmmirror.com

# Or set permanently
npm config set registry https://registry.npmmirror.com
4Check proxy and VPN settings

If behind a proxy, ensure npm is configured correctly:

bash
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

Try disconnecting from VPN if possible.

5Clear npm cache and retry

A corrupted cache can cause connection issues:

bash
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
6Install packages in smaller batches

For large projects, install dependencies in groups:

bash
npm install package1 package2
npm install package3 package4
# Continue until all installed

Advanced notes

In CI/CD environments, consider using npm ci with increased timeouts and retry logic. Docker builds may need --network-timeout flags. For corporate networks, work with IT to whitelist registry.npmjs.org and its CDN endpoints. Consider using a local npm proxy like Verdaccio or Nexus for frequently used packages to reduce external network dependency.

Frequently asked questions

What does "npm ERR! ESOCKETTIMEDOUT" mean?
ESOCKETTIMEDOUT means npm's network socket connection timed out while trying to communicate with the npm registry or another remote server. Unlike ETIMEDOUT which occurs during connection establishment, ESOCKETTIMEDOUT typically happens when a connection was established but the data transfer took too long. This error indicates that while npm was able to start a connection, the remote server stopped responding during the data exchange, or the network became too slow to complete the transfer within the allowed timeout period.
How do I fix "npm ERR! ESOCKETTIMEDOUT"?
The ESOCKETTIMEDOUT error occurs when npm cannot establish or maintain a network connection to the registry within the expected time. This typically indicates network issues, slow connections, or registry unavailability.
What causes "npm ERR! ESOCKETTIMEDOUT"?
Slow or unstable network connection npm registry server experiencing high load Corporate proxy or firewall throttling connections
Is the "npm ERR! ESOCKETTIMEDOUT" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading