npm install stops with a response timeout while fetching a package
Response 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.
Fix it fast
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 registry2Match what you see, then jump to its fix
- 1
npm config get fetch-timeout prints a small number such as 30000fetch-timeout is set too low for the connectionFix - 2
The failure is random: the same install passes on a second tryRetries are too few for a flaky networkFix - 3
Browsers 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
npm config get registry prints a URL other than https://registry.npmjs.org/The registry setting points at a slow or unreachable mirrorFix
- 1
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 list2Fix
Raise the timeout, or delete the low override from the .npmrc file that sets it.
npm config set fetch-timeout 6000003Verify
Run the install again.
npm installConfirmed by docs.npmjs.com
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-maxtimeout2Fix
Allow more tries and a longer wait between them.
npm config set fetch-retries 5
npm config set fetch-retry-maxtimeout 1200003Verify
Repeat the install on the same network.
npm installConfirmed by docs.npmjs.com
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 noproxy2Fix
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:80803Verify
Run the install again.
npm installConfirmed by docs.npmjs.com
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 registry2Fix
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 installConfirmed by docs.npmjs.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix