How to fix npm ERR! code E408 npm ERR! 408 Request Timeout in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025ยท 141 views

The E408 error occurs when npm's request to the registry exceeds the timeout limit, usually due to slow connections or registry latency. This prevents package installation or updates from completing.

Quick fix

Fixes npm ERR! code E408 npm ERR! 408 Request Timeout

npm config set fetch-timeout 300000
npm config set fetch-retry-maxtimeout 120000
npm config set fetch-retry-mintimeout 20000
  1. Increase npm timeout configuration
  2. Clear npm cache and node_modules
  3. Switch to a faster npm registry mirror
  4. Configure proxy settings if behind corporate network
npm โ€” error
npm config set fetch-timeout 300000
npm config set fetch-retry-maxtimeout 120000
npm config set fetch-retry-mintimeout 20000
npm ERR! code E408
npm ERR! 408 Request Timeout

What this error means

npm ERR! code E408 is a 408 Request Timeout error that happens when npm tries to fetch a package from the registry but the request takes longer than the configured timeout period (default 30 seconds). This typically occurs during `npm install`, `npm update`, or `npm publish` operations when the registry server is slow to respond, your internet connection is unstable, or a large package metadata file exceeds the time limit. The error indicates that npm sent a request but didn't receive a response within the expected timeframe. Rather than hanging indefinitely, npm cancels the request and reports the timeout, allowing you to retry or adjust settings. This is a network-level issue, not a problem with your code or the package itself.

Typical symptoms

  • npm install stops mid-process with 'E408 Request Timeout' message
  • Installation hangs for 30+ seconds before failing
  • Specific packages consistently fail to download while others succeed
  • npm works fine on mobile hotspot but fails on office Wi-Fi
  • CI/CD pipelines timeout during npm install step

Common causes

  1. Slow or unstable internet connection not meeting npm's speed requirements
  2. npm registry server experiencing high load or temporary slowness
  3. Firewall or proxy intercepting requests and delaying responses
  4. Default timeout value (30 seconds) too short for your network conditions
  5. VPN or corporate network proxy adding latency to registry requests

How to fix "npm ERR! code E408 npm ERR! 408 Request Timeout"

1Increase npm timeout configuration

The quickest fix is to increase npm's timeout values to accommodate slower connections:

bash
npm config set fetch-timeout 300000
npm config set fetch-retry-maxtimeout 120000
npm config set fetch-retry-mintimeout 20000

These settings mean:
- fetch-timeout: 5 minutes (300000ms) for the entire request
- fetch-retry-maxtimeout: 2 minutes between retries
- fetch-retry-mintimeout: 20 seconds minimum before first retry

Alternatively, add these directly to ~/.npmrc:

bash
fetch-timeout=300000
fetch-retry-maxtimeout=120000
fetch-retry-mintimeout=20000
fetch-retries=5
2Clear npm cache and node_modules

Corrupted cache or lock files can cause timeouts. Remove the cache and local dependencies, then reinstall:

bash
npm cache clean --force
rm -rf node_modules package-lock.json
npm install

This forces npm to download fresh from the registry without using cached metadata that might be causing issues.

3Switch to a faster npm registry mirror

If the official npm registry is slow in your region, use a mirror. Popular alternatives include:

bash
# Use npmmirror (good for Asia)
npm config set registry https://registry.npmmirror.com/

# Switch back to official registry
npm config set registry https://registry.npmjs.org/

Mirrors often have better latency in specific regions and can significantly reduce timeout issues.

4Configure proxy settings if behind corporate network

If you're on a corporate network, proxy settings might be missing or incorrect:

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

If you don't need a proxy, remove these settings:

bash
npm config delete proxy
npm config delete https-proxy

You can also check current settings with:

bash
npm config list
5Retry with verbose output and network diagnostics

Run the install with verbose logging to identify which package is timing out:

bash
npm install --verbose

If a specific package is the culprit, try installing it alone:

bash
npm install package-name@latest --verbose

Check your network connectivity:

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

If pings are slow (>100ms) or curl hangs, your network connection is the issue.

Advanced notes

For CI/CD environments (GitHub Actions, GitLab CI, etc.), add timeout configuration to your workflow YAML. Use the --no-audit flag to skip security audits which can add time: npm install --no-audit --prefer-offline. If using yarn or pnpm, they handle slow connections better with retry logic and parallel downloads, making them alternatives worth considering.

Frequently asked questions

What does "npm ERR! code E408 npm ERR! 408 Request Timeout" mean?
npm ERR! code E408 is a 408 Request Timeout error that happens when npm tries to fetch a package from the registry but the request takes longer than the configured timeout period (default 30 seconds). This typically occurs during npm install, npm update, or npm publish operations when the registry server is slow to respond, your internet connection is unstable, or a large package metadata file exceeds the time limit.
How do I fix "npm ERR! code E408 npm ERR! 408 Request Timeout"?
The E408 error occurs when npm's request to the registry exceeds the timeout limit, usually due to slow connections or registry latency. This prevents package installation or updates from completing.
What causes "npm ERR! code E408 npm ERR! 408 Request Timeout"?
Slow or unstable internet connection not meeting npm's speed requirements npm registry server experiencing high load or temporary slowness Firewall or proxy intercepting requests and delaying responses
Is the "npm ERR! code E408 npm ERR! 408 Request Timeout" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading