Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

npm install stops with a response timeout while fetching a package

ErrorResponse timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms)

Short answer

npm gave up waiting for the registry. Current npm waits five minutes by default, so a 30000 ms message means a lower fetch-timeout is configured, or an old npm is running. Check the config, raise fetch-timeout and fetch-retries, then check proxy settings and that the registry URL is the one you intend.

  • Applies to npm 10, npm 11, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the timeout, retry and registry values npm is really using. npm reads a per-project .npmrc, a per-user .npmrc, a global one and a built-in one, so a project file can override your own.

    npm -v
    npm config get fetch-timeout
    npm config get fetch-retries
    npm config get registry
  2. 2Match what you see, then jump to its fix

    1. 1npm config get fetch-timeout prints a small number such as 30000fetch-timeout is set too low for the connectionFix
    2. 2The failure is random: the same install passes on a second tryRetries are too few for a flaky networkFix
    3. 3Browsers on the same network reach the internet but npm waits until it times outA proxy is required but npm is not set to use itFix
    4. 4npm config get registry prints a URL other than https://registry.npmjs.org/The registry setting points at a slow or unreachable mirrorFix

What does the error look like?

  • Response timeout while trying to fetch https://registry.npmjs.org/react-is (over 30000ms)

Cause 1 of 4

fetch-timeout is set too low for the connection

1Check

npm's configuration reference lists fetch-timeout as the maximum time to wait for HTTP requests, with a default of 300000 ms (five minutes). A smaller value in an .npmrc cuts requests short on slow links.

npm config list

2Fix

Raise the timeout, or delete the low override from the .npmrc file that sets it.

npm config set fetch-timeout 600000

3Verify

Run the install again.

npm install

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 4

Retries are too few for a flaky network

1Check

npm retries idempotent reads after network failures or 5xx answers; the number is fetch-retries (default 2) and the waits between tries are fetch-retry-mintimeout and fetch-retry-maxtimeout.

npm config get fetch-retry-mintimeout fetch-retry-maxtimeout

2Fix

Allow more tries and a longer wait between them.

npm config set fetch-retries 5
npm config set fetch-retry-maxtimeout 120000

3Verify

Repeat the install on the same network.

npm install

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 4

A proxy is required but npm is not set to use it

1Check

npm reads proxy and https-proxy from its config or from the HTTP_PROXY and HTTPS_PROXY environment variables, and noproxy lists domains that skip the proxy.

npm config get proxy
npm config get https-proxy
npm config get noproxy

2Fix

Set the proxy that your network requires.

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

3Verify

Run the install again.

npm install

Confirmed by docs.npmjs.com

Did this fix it?

Cause 4 of 4

The registry setting points at a slow or unreachable mirror

1Check

The registry config is the base URL of the npm registry, with https://registry.npmjs.org/ as the default. A company mirror or an old address left in .npmrc is slow or down.

npm config get registry

2Fix

Reset it to the default, or to the mirror you really want.

npm config set registry https://registry.npmjs.org/

3Verify

Run the install again.

npm install

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Keep timeout, proxy and registry overrides in one place, and note why each exists.
  • Update npm so its defaults match the current documentation.
  • Use a lockfile and a CI cache so installs do not depend on a slow link every time.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.