267

I'm having a problem with npm, I cant install anything. Here is the error messages:

C:\Windows\system32>npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm ERR! network read ECONNRESET
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settin
gs.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "yo"
npm ERR! cwd C:\Windows\system32
npm ERR! node -v v0.10.17
npm ERR! npm -v 1.3.8
npm ERR! syscall read
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Windows\system32\npm-debug.log
npm ERR! not ok code 0

Any idea why is this? Here are my network settings and it seems I dont have any proxy configured. I also disabled all the firewalls.

enter image description here

6
  • Are you able to visit this page in a browser registry.npmjs.org/yo? Commented Aug 24, 2013 at 13:47
  • It appears their SSL certificate expired! Commented Aug 24, 2013 at 20:16
  • @thefourtheye Yes I can visit that link Commented Aug 25, 2013 at 7:38
  • npm doesnt install anything. This problem isnt exclusive in installing express Commented Aug 25, 2013 at 8:21
  • You may need to check C:\Windows\system32\npm-debug.log, this file will have more accurate information to resolve your problem. Commented Aug 18, 2017 at 5:39

36 Answers 36

470

Try setting the npm registry to HTTP by running:

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

so that npm requests for http url instead of https and then try the same npm install command.

TL;DR:

Looks like you are having problem with npm while trying to install packages, getting ECONNRESET error. This usually means there is some issue with network connectivity, which might be due to proxy settings or firewalls.

To fix this issue, you can try these steps:

  1. Set npm Registry to HTTP: Sometimes using HTTPS can create problems with certain network setups, especially if there are SSL certificate issues or problems with proxy. So, you can switch to HTTP version of npm registry by running this command:

    npm config set registry http://registry.npmjs.org/
    
  2. Try Installation Again: After changing the registry, try running your install command again:

    npm install -g yo
    
  3. Check Proxy Settings: Since you said you don’t have any proxy configured, make sure npm settings also reflect that. You can check current npm proxy settings by running:

    npm config get proxy
    npm config get https-proxy
    

    If these show any value, you may want to delete them by using:

    npm config delete proxy
    npm config delete https-proxy
    
  4. Network Configuration: If still having issues, check if your network connection is stable. You can try connecting to different network or check if any firewall or antivirus is blocking npm connections.

  5. Update Node and npm: You are using very old versions of Node.js and npm. If possible, try to update to latest versions.

  6. Check Logs: If problem still continues, look at the log file mentioned in error message (C:\Windows\system32\npm-debug.log) for more details about error.

Sign up to request clarification or add additional context in comments.

8 Comments

can you please also provide some explanation , it will be very helpful.
This "fix" is susceptible to man-in-the-middle attacks. I wouldn't use this for production.
The problem could easily be you are being blocked to that website by your ISP's or Company's firewall/proxy. Using the above method is quicker and easier but it's also insecure as it doesnt verify you are connected to the right website. To check if you are being blocked simply go to registry.npmjs.org in your browser. You should get some text back.
haha....I'd been trying to get past this off and on for months. I had been just disabling VPN, grabbing packages, then logging back on. Thanks for this. All others, issue is simply your proxy address/port is wrong or (in this case) your proxy is not configured to listen for HTTPS traffic.
I know it may not be secure but come on - I TRIED EVERYTHING to get rid of ECONNRESET error while creating new angular 4 app via Angular CLI and that solution only worked. After creating new project you can switch back to https. Anyway @mithunsatheesh thank you once again.
|
89

You may want to check your NPM proxy settings and perhaps remove it.

npm config get proxy
npm config rm proxy
npm config rm https-proxy

One might expect a fresh install of NodeJS+NPM would not have a proxy configured. Strangely enough, mine did come with a proxy defined, pointing to an IP and port 3128. Removing the proxy did the trick.

4 Comments

I was trying to install jquery in Angular project using the cmd - npm install jquery But there was a proxy error which is now resolved when tried this solution.
After a day, I have solved my problem npm ERR! network In most cases you are behind a proxy or have bad network settings with this solution. Thanks
This actually worked, and it seems to be more secure than the other solution.
This worked for me also. Unfortunately the earlier solution not worked.
23

Remove your proxy settings at home and switch on at Office networks, This may be irritating, But It worked for me:

npm config set proxy http://xxx.xxx.xxx.4:8080   
npm config set https-proxy http://xxx.xxx.xxx.4:8080

and

npm config rm proxy   
npm config rm https-proxy

2 Comments

The last bit worked for me - I checked my .npmrc file and the old https proxy was still there after removing the proxy
this is working but how to unconfigure or reconfigure to default, whenever go to other network with out proxy??
18

You may also need to specify the proxy server/port, in some environments the system settings for proxy are not enough for npm to work.

    npm config set proxy "http://your-proxy.com:80"

Comments

15

This can be caused by installing anything with npm using sudo -- this causes the files in the cache to be owned by root, resulting in this problem. You can fix it by running:

sudo rm -rf ~/.npm

to remove the cache. Then try whatever you were doing again, making sure you never use sudo along with npm (or the problem may come back).

Lots more information: npm throws error without sudo

4 Comments

forgot about needing to elevate to Administrator to perform npm -g update (as I did to install it). Thanks.
How does this cause ECONNRESET, exactly? You're right that sudo can break things in novel ways, but causing the registry server to drop connection is a bit unbelievable.
This worked for me! I was trying to do npm i next-pwa and got similar error as mentioned in the question. Didn't have a proxy set so other solutions didn't work for me. I remembered having used sudo and npm commands together previously so tried this solution and hopefully it worked as well. Loads of thanks @Kevin!
Using npm as a non-root user worked for me but I did not need to remove the .npm folder. I also used the chown command to remove the root ownership of some folders.
14

Restarting my PC made it work.

4 Comments

So true, tried all the other solutions, this worked. But in my case, I also ran the sudo apt update -> sudo apt upgrade before deleting my node_modules folder and tried installing again only to encounter this error. Restart fixed it for me.
Solution that legends doo
A few days ago, I got this issue and did not even need to restart the computer. Retrying the installation fixed the issue (I modified an installation script in order to resume installation instead of starting from scratch).
It's funny how the simplest solutions fix the biggest problems. worked for me as well (after trying all of the above .... )
9

Remove yarn.lock , package-lock.json, node_modules

and then

npm install -f 

Worked for me

Comments

5

The three thing to make npm working well inside the proxy network .

This set npm registry , By default it may take https.

npm config set registry "http://registry.npmjs.org/"

Second is two set proxy in your system . If your organization use proxy or you.

npm config set proxy "http://username:password@proxy-url:proxy-port"

npm config set https-proxy "http://username:password@proxy-url:proxy-port"

You can also check if they are set or not , by

npm config get https-proxy

for all values.

4 Comments

It does not show me any error, but installation is stuck at line - loadRequestedDeps: sill install loadAllDepsIntoIdealTree
This is another issue . The proxy issue of your is solved . May this short your thing stackoverflow.com/questions/40874237/…
Configuring http instead of https is deprecated since 2021. github.blog/security/supply-chain-security/…
And its also at least 250% slower.
5

npm config rm proxy

npm config rm https-proxy

works for me!

Comments

5

I've tried almost all methods posted here and in other pages but didn't work. Here are the commands I've executed in order, which I encourage you to try because it worked for many people (but not me):

  • npm config rm proxy
  • npm config rm https-proxy
  • npm config set https-proxy https://username:[email protected]:6050
  • npm config set proxy http://username:[email protected]:6050
  • npm config set registry http://registry.npmjs.org/

And then trying to install the package npm install -g express, but it failed.

However, when I tried to run npm install npm@latest -g it miraculously executed and installed fine!
Then running npm install -g express again worked perfectly fine too.

TL;DR: updating npm to the latest version solved the issue (currently 6.0.1)

Comments

4

I had the same issue in windows while installing any package from npm. Fixed that with - ** open command prompt as administrator and run these 3 commands **/

1. npm config rm proxy

2. npm config rm https-proxy

3. npm install npm@latest -g

FOR MAC / LINUX
1. sudo npm config rm proxy

2. sudo npm config rm https-proxy

3. sudo npm install npm@latest -g

Basically this was version isuue with npm . Please check its worrking

Comments

3

This is an old question, but anyway.

I had this issue, when I was trying to deploy to heroku, and the fix that worked for me was to update the npm version that was used. I had version 2.x.x and I updated to 3.x.x

1 Comment

Or specify an npm version compatible with the node engine being used.
3

This is what worked for me:

proxy = http://1.1.1.1:3128/
https_proxy = http://1.1.1.1:3128/
strict-ssl = false
ca = null
registry = http://registry.npmjs.org/

Answer found here: https://fak3r.com/2015/07/31/howto-use-npm-behind-a-corporate-proxy/

1 Comment

My company network have proxy I fixed by check .npmrc file by company registry config: .npmrc file content: registry=IP:PORT/repository/npm-group always-auth=true strict-ssl=false
3

I had the same issue but none of these solutions worked correctly. Finally, I have installed packages via yarn, which is npm-compatible. As per official website:

Migrating from npm should be a fairly easy process for most users. Yarn can consume the same package.json format as npm, and can install any package from the npm registry.

Just install the yarn and then then, run the install by using the following command, the equivalent to npm install in yarn:

yarn install

Read more at Yarn: Migrating from npm.

1 Comment

yarn is managing issues with the network - retrying, instead of aborting like npm
2

At work, i had to load up my browser and browse a webpage (which authenticates me to our web-filter). Then I retried the command and it worked successfully.

1 Comment

Not 100% sure if this is what helped me, or just a coincidence, but navigating to registry.npmjs.org in Firefox somehow helped npm install work the next time. I don't have any kind of web filter software.
2

You may also encounter this error if you have a saved bearer token that is now invalid. I've encountered this when using a private repo where the accounts were wiped and reset, invalidating the tokens. Although your repo may not require authentication, if you have a token from a previous login it will be passed and if it's invalid your connection will be closed.

You can resolve this by either logging in again with the new user name and password, or presumably by simply logging out via npm.

Comments

2

I did not want to switch to http for the registry, what worked for me was downgrading from the latest Node version to the LTS version (as of now, 6.x).

Comments

2

I had the problem with npm throwing this error.

So basically whenever error was thrown i either used manual install
from git or waited and installed specified version like:

npm install resolve@^1.1.6

when running alone:

npm install resolve

didn't worked.

I updated node.js from 7 to 8 and npm install goes smoothly.

I think that maybe the version 7 caused this problem since @luschn downgraded to 6 so he didn't use 7 too.

Maybe the registry itself is returning errors without showing problems on their status pages because after some time i could install this one breaking package and then proceed with npm install to install the rest.

Comments

2

I had the same problem on my local home network without proxy. Other answers in this thread didn't work for me. What I ended up doing was using yarn which can be used interchangeably with npm:

yarn add

To this day I don't know why my npm still don't work. I know for sure that it's a problem with my Wi-Fi, because when I connect to LTE internet broadcasted from my smartphone npm install works again. It has probably something to do with router settings (problems started when I upgraded my internet speed and ISP worker replaced my old router with a new one).

Comments

2

I had the same problem when trying to run npm on system emulated in Oracle VirtualBox. I resolved it by adding Google DNS address in Network Adapter properties.

Network Adapter properties > IPv4 properties > Preferred DNS address: 8.8.8.8.

Comments

2

Our company firewall will stop installing node hence connect to the personal network and install, it worked for me.

Comments

2

I found "npm config edit" to be more useful to update the entries for https-proxy, proxy, registry

I did something like this

  • npm config list
  • npm config edit (opens in vi)
  • Edit or set the config entries for https-proxy, proxy, registry
  • npm install

Comments

2

Just in case...simply trying one more time worked for me. It could just be a temporary connection issue.

Comments

2

If you're using Windows you should follow up on Advanced System Settings to check the env vars declared over there, you should notice that the proxy configuration may lie within environment variables, like in the picture below:

Windows env vars

So if your proxy server is not available or is blocking traffic from npm you might notice the aforementioned error in this topic. Maybe you don't need any proxy at all, in this case, just remove this HTTP_PROXY env variables.

I had turned all proxy configurations off in my Windows and npm settings, however, npm was still getting timeout and connection errors while downloading resources, then I figured out there was still a proxy configuration left on env variables, which was causing all the trouble.

Comments

2

In my case, I was running a Node JS application in another CMD, and that application was listening to port 8088.

So when I was executing any command related to npm it was throwing the above error.

The solution in my case was: Stopping ANY Running Node JS applications and retrying to execute the npm command again. the installation should be completed successfully, without any errors.

Comments

1

npm config set https-proxy "http://username:password@proxy-url:proxy-port" worked for me

Comments

1

In case this helps anyone who was in my situation: I recently installed Fiddler, which (unbeknownst to me) added a network proxy through 127.0.0.1:8866. I went into my Ubuntu network settings, clicked into the "Network Proxy" settings, and disabled it, and then all was back to normal.

So in general, check to make sure you haven't got a network proxy set up due to a side-effect of something else you were doing.

Comments

1

I found a simple solution for this. if you are using windows 10 then go to the network setting and turn off the automatic proxy detection.it solved my problem. I was looking for this for the last 2 days.

Comments

1

In my case changing wifi works for me. I usually work in my living room. But I changed to my room just a few days ago. The wifi did not reach the 2nd floor so we used Wifi Extender.

Then I had this issue. I tried switching back to my living room's wifi and I got no problem from doing the same command.

2 Comments

Thank you for sharing this - same problem and same solution!!
Haha glad it helped @RichardFoss apparently it's a network issue as the error implied I guess ECONNRESET, connection reset stuff.
1

If you live in China, try the below command, it's the npm mirror registry, and supports https:

npm config set registry https://registry.npmmirror.com/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.