npm ERR! Error: connect ECONNREFUSED when trying to update the npm - node.js

I'm trying to update the npm (node package manager) using the command:
npm install npm#latest -g
but I'm getting the following error in the command prompt:
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "npm#latest" "-g"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect
npm ERR! Error: connect ECONNREFUSED xxx.xxx.xx.xxx:xxx
npm ERR! at Object.exports._errnoException (util.js:1022:11)
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
does someone know what this really means?
any help would be appreciated.

Try:
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
The first two lines will remove proxy's if there any.
Third line will make npm download from the official package registry.

If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config'
See:
https://docs.npmjs.com/cli/config
More info:
How to setup Node.js and Npm behind a corporate web proxy

I have been trying to fix this issue by
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myproxyblabla:myport
npm config set https-proxy http://myproxyblabla:myport
But it didn't help. The only one solution which worked for me is adding additional fields to host file (C:\Windows\System32\drivers\etc\hosts)
151.101.36.162 registry.npmjs.com
151.101.36.162 registry.npmjs.org
This allowes npm to resolve address to server from which it will download needed files.
You can get familiar with closed issue on npm repository where this solution is approved by npm contributors.

I got a similar error when I was using Node JS behind a proxy server. Here's what I had to do to fix it:
npm config set proxy http://jdoe:password123#proxy.company.com:8080
npm config set https-proxy http://jdoe:password123#proxy.company.com:8080
Just replace "jdoe" and "password123" with your own credentials to access the proxy server. Everything after the # is the server domain name, or you can enter the exact IP address too. In my case, both addresses were HTTP (not HTTPS).
To confirm the changes, you can type:
npm config list
and your settings should be listed.
You can get the proxy settings (address) from your browser too.

May be this will help someone in need. I turned to this solution after wasting good 2 hours as my corporate proxy server on work laptop was not getting resolved..!
I removed both proxy and https-proxy from .npmrc file and set only
npm config set registry http://registry.npmjs.org/
Then, I am able to successfully run npm install -g create-react-app
.npmrc file can be found here at C:\Users\<userName>\.npmrc
Cheers! Happy Quarantine Development :p

The problem here is because of proxy. So you need to run the below-mentioned command to remove the proxy and then set the registry from http://registry.npmjs.org/.
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
And then you can create your first react app by using:
npx create-react-app your-app-name

I had the same problem with my cra and all I had to do was comment out my .npmrc, clean the cache, and run the command npx create-react-app

We faced similar issue recently and our requirement was to use public npm registry for one feature and private registry for another feature. So for private registry npm needs to go via proxy but for public registry we don't need proxy so we created .npmrc file inside our project and added two config variables:
registry and noproxy where noproxy points to the public domain of the registry. This will make sure to skip the proxy config from your global npmrc file.

I had the same error, using Mullvad VPN. It was fixed by enabling IPv6 in Mullvad settings.

We happened to run into this error message because in our setup, the Maven Nexus NPM Repository ran on the same machine and we therefore first used http://localhost/xyz/ as the NPM repository URL.
For whatever reason, localhost was treated as a system-type NPM registry, causing errors.
Changing the NPM repository URL configuration to the computer's hostname, e.g. http://mycomputer.company.intra/xyz/ fixed the issue.

What fixed it for me, was to enable SMB 1.0 in Window's Control Panel on my development PC as follows:
Control Panel > Programs and Features > Turn Windows features on or off > SMB 1.0

Related

How do I remove corporate proxy? I have tried everything, nothing works

I have an artifactory preventing me from setting up any new apps or libraries. When I had access to corporate VPN, I could bypass it.
I am basically getting this when trying any npm install:
npm ERR!
403 Forbidden - GET https:// (artifactory link)
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
I have tried this:
npm config rm proxy
npm config rm https-proxy
I have even reinstalled Git and Node. Nothing works. Please help!
Try to set noproxy
https://docs.npmjs.com/cli/v8/using-npm/config#noproxy
npm config set noproxy "my-proxy-host"
You can set your npm registry to the default registry
use the following command:
npm config set registry https://registry.npmjs.org/

Request to http://registry.npmjs.org/check failed, reason: connect ECONNREFUSED

When I run this commend "npm install -g check" on cmd I have the following error
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://registry.npmjs.org/check failed, reason: connect ECONNREFUSED 10.141.0.60:80
using:
OS: Windows 10
Node Version: v8.10.0
npm version: 5.6.0
Domain (AD): kmsd
User: mu789
Proxy: 10.40.140.60:4000
I tried following commends, but still have the same issue
npm set strict-ssl=false
npm config set registry "http://registry.npmjs.org/"
npm config set proxy http://kmsd\mu789:ab_132#10.40.140.60:4000/
npm config set https-proxy http://kmsd\mu789:ab_132#10.40.140.60:4000/
--
npm config set proxy http://kmsd%5Cmu789:ab_132#10.40.140.60:4000/
npm config set https-proxy http://kmsd%5Cmu789:ab_132#10.40.140.60:4000/
--
npm config set proxy http://mu789:ab_132#10.40.140.60:4000/
npm config set https-proxy http://mu789:ab_132#10.40.140.60:4000/
--
.npmrc
proxy=http://kmsd\mu789:ab_132#10.40.140.60:4000/
https-proxy=http://kmsd\mu789:ab_132#10.40.140.60:4000/
--
.npmrc
proxy=http://"kmsd\mu789:ab_132"#10.40.140.60:4000
https-proxy=http://"kmsd\mu789:ab_132"#10.40.140.60:4000
--
.npmrc
proxy="http://kmsd\mu789:ab_132#10.40.140.60:4000/"
https-proxy="http://kmsd\mu789:ab_132#10.40.140.60:4000/"
I tried all methods in Is there a way to make npm install (the command) to work behind proxy? but still have the issue.
format for proxy "http://mu789:kmsd#10.40.140.60:4000" which should be put in .npmrc file.
Please try this and check if you still face this isue.
Assuming kmsd is password for the corp
I had the same issue, was able to successfully install it outside my company's corporate network or try adding the proxy to proxy bypass list. Hope it helps!

Resolving network tunneling socket could not be established error

While trying to install node-inspector, I am getting the error:
npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/home/hira/.nvm/versions/node/v4.4.7/bin/node" "/home/hira/.nvm/versions/node/v4.4.7/bin/npm" "install" "-g" "node-inspector"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ECONNRESET
npm ERR! network tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:5002
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 settings.
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! Please include the following file with any support request:
I basically had a project based on node's thin module, that ran an http/https mitm proxy on 127.0.0.1:5002
Reading some answers on this issue, I have tried to remove the proxy settings by using:
npm config rm proxy
npm config rm https-proxy
as well as
npm config set proxy = null
so when I do npm config ls -l it shows both settings as null. However, still it refuses to install. I have even tried to remove my systems Network Proxy settings.
Could anyone help with this issue? I am running node v4.4.7 and npm version 2.15.8 on Ubuntu 16.04 on Virtualbox. Thanks.
As indicated by robertklep and QPTR in comments, removing the environment variables solved it for me
http_proxy
https_proxy
HTTPS_PROXY
HTTP_PROXY
Below things worked for me, make sure environment variable HTTP_PROXY is unset before removing config entries. First line is very important.
set HTTP_PROXY=
npm config rm proxy
npm config rm https-proxy
npm config rm http-proxy

Getting errors with npm when installing nativescript

i am trying to install nativescript, i am new to it so i'll appreciate any help..
first , i installed it correctly but after that i saw a page on nativescript site for advanced installation, so i played around with it .. now i cannot run the command tns and cannot uninstall, can`t install..
here is the errors i get:
note: I also updated my nodejs to the newest version , but couldnt update npm , when i tried to run: npm install npm -g i got errors like here:
i also tried rebooting the pc but didn`t help.
i uninstalled node, npm then installed them again .. now i get this error :
ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
ERR! network This is most likely not a problem with npm itself
ERR! network and is related to network connectivity.
ERR! network In most cases you are behind a proxy or have bad network settings.
ERR! network
ERR! network If you are behind a proxy, please make sure that the
ERR! network 'proxy' config is set properly. See: 'npm help config'
ERR! Please include the following file with any support request:
ERR! C:\Users\Home\npm-debug.log
It was a connection problem.
I remember thatI played with proxy configuration by mistake like this :
npm config set proxy http://localhost:8080/
npm config set https-proxy http://localhost:8080/
npm config set strict-ssl false
which made npm client attempts to hit localhost:8080 to pull the module rather than the correct internet endpoint.
so after couple of days of frustration i visited this link
https://docs.npmjs.com/cli/config
then run
npm config edit
which opened a file inside that file i removed those three lines i added above , then everything worked fine.

NPM doesn't install any modules: network socket hangs up

Salam (means Hello) :)
I have the latest version of node.js installed on ubuntu 12.04, I'm not behind any proxies, and my network settings are correctly configured, and were intact since last time when NPM worked fine. But now NPM hangs up installation of any modules with following error:
nasser#nasser-desktop:~/projects/server v3$ npm install simple-proxy
npm WARN package.json docco#0.6.2 No repository field.
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm ERR! network socket hang up
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 settings.
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 Linux 3.5.0-17-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "simple-proxy"
npm ERR! cwd /home/nasser/projects/serverV3
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/nasser/projects/serverV3/npm-debug.log
npm ERR! not ok code 0
i had same problem.
it seems that there is some problem with ISP's https handling. doing:
npm config set registry http://registry.npmjs.org/
worked for me
I was having the same problem. Found a solution in this thread.
You can see the effective proxy that npm is using by doing:
npm config get proxy
npm config get https-proxy
If you're behinid a proxy, try this:
mv ~/.npmrc ~/.npmrc.bak
I was having a similar issue with my windows machine and i fixed it by first checking whether my proxy got some value by executing the below command.
npm config get proxy
in return i got the below:
http://usr:pwd#host/:port
So if anyone who is not under a proxy layer first set the proxy as null by executing the below command.
npm config set proxy null
now if you excecute your npm i it should not throw any network error.
I tried multiple solution but most of cases happened with me is network/ssl and proxy issue.Network/ssl cases are very common and there are bunch of solution but with proxy thing I shared my fixes with you.
Bash Commands:
npm config set proxy null
npm config set https-proxy null
npm config set http-proxy null
in my case I'm using https://registry.npmjs.org/ url.
After NULL proxy its start working.
npm set default proxy as http://my-proxy.com:1080/ so either we have to change proxy url or null it.
To get your default proxy hit below command in your bash.
npm config get proxy
If you are behind a proxy that has username and password authentication, try setting the proxy as
npm config set proxy http://username:encodedpassword#proxyaddress:port
npm config set https-proxy http://username:encodedpassword#proxyaddress:port
Just follow these steps before you run: npm install -g #angular/cli
npm cache clean (You can even ignore if it throws an error)
npm config set strict-ssl false
npm config set proxy http://myusername:mypassword#proxyaddress:port
npm config set https-proxy http://myusername:mypassword#proxyaddress:port
Add the proxy and http_proxy field with your credentials (encoded if it contains any special characters) to your .npmrc file and run npm install again. It should work.
for example:
proxy=http://username:passcode#proxyURL:80/
https_proxy=http://username:passcode#proxyURL:80
Find .npmrc file, open with note pad. then delete the proxy setting there

Resources