[npm] Error 'tunneling socket' while executing npm install

I'm getting the error shown below while trying to execute 'npm install' command.

Error: tunneling socket could not be established, cause=connect ECONNREFUSED 10.232.207.137:8080

What do I miss?

screenshot

This question is related to npm protractor

The answer is


remember to set you username and password if required:

http://USERNAME:[email protected]:8080

Example:

npm config set proxy http://USERNAME:[email protected]:8080

I had this same error when trying to install Cypress via npm. I tried many of the above solutions as I am behind a proxy, but was still seeing the same error. In the end I found that my WIndows system configuration(can be checked by entering 'set' in command prompt) had HTTP and HTTPS proxys set that differed from the ones vonfigure in npm. I deleted these proxys and it downloaded staright away.


In my case helped delete .npmrc config file

rm ~/.npmrc

Following commands may solve your issue:

npm config set proxy false
npm cache clean

It solved my same issue.


If you using gnome, and turned off the proxy at the network level, you also need to make sure you don't have proxy enabled in your terminal

? gconftool-2 -a /system/http_proxy  
 host = http://localhost/
 port = 2000
 use_http_proxy = false
 use_authentication = false
 authentication_password = 
 authentication_user = 
 ignore_hosts = [localhost,127.0.0.0/8]

You can drop it with

gconftool-2 -t string -s /system/http_proxy/host ""
gconftool-2 -u /system/http_proxy/port
gconftool-2 -u /system/http_proxy/host
unset http_proxy

Next to what has described @Roshith in his answer here:

If you are behind a proxy, set it correctly in npm.

npm config set proxy http://proxyhost:proxyport
npm config set https-proxy http://proxyhost:proxyport

I had to change also the the file ~.bashrc which also contained a worng proxy setting in my case. I changed those settings here:

export HTTP_PROXY="http://proxyhost:proxyport"
export HTTPS_PROXY="http://proxyhost:proxyport"

Use the following command to verify the proxy settings:

env | grep -i proxy

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

above code solved my issue :)


I spent days trying all the above answers and ensuring I had the proxy and other settings in my node config correct. All were and it was still failing. I was/am using a Windows 10 machine and behind a corp proxy.

For some legacy reason, I had HTTP_PROXY and HTTPS_PROXY set in my user environment variables which overrides the node ones (unknown to me), so correcting these (the HTTPS_PROXY one was set to https, so I changed to HTTP) fixed the problem for me.

This is the problem when we can have the Same variables in Multiple places, you don't know what one is being used!


Removing the proxy settings resolved the issue:

If you are no using any proxy:

npm config rm proxy
npm config rm https-proxy

If you are using Proxy:

npm config set proxy http://proxyhostname:proxyport
npm config set https-proxy https://proxyhostname:proxyport

Hopefully this will solve your problem :)


I know this is way too late but if someone has a similar issue in the future and you are sure you have no proxy set but you have an environment variable called http_proxy. Please delete it and try again. I had set a proxy for Fiddler.


according to this it's proxy isssues, try to disable ssl and set registry to http instead of https . hope it helps!

npm config set registry=http://registry.npmjs.org/
npm config set strict-ssl false

I faced similar and tried some of the techniques mentioned here. To overcome,

I performed a cleanup of duplicate entries in c:\users\<user name>\.npmrc

Hope it helps someone. Thanks,


If you are behind a proxy, set it correctly in npm.

>npm config set proxy http://proxyhost:proxyport
>npm config set https-proxy http://proxyhost:proxyport

Notes:

  1. For SSL/https proxies, the protocol in URL should be http not https

  2. If your set up is on a Docker/Vagrant instance or a hosted VM, use IP address instead of hostname for proxy as the later might not be resolvable.

  3. If there is no proxy , remove proxy config from npm

    >npm config set proxy null
    >npm config set https-proxy null
    

I also ran into the similar issue and was using CNTLM for proxy configuration. In my case HTTP_PROXY and HTTPS_PROXY are taking higher precedence over http_proxy and https_proxy so be aware of changing all proxy variables.

env|grep -i proxy

and make sure all of the below proxy variables should point to the same proxy.

HTTP-PROXY = "http://localhost:3128"
HTTPS-PROXY = "https://localhost:3128"
HTTPS_PROXY = "http://localhost:3128"
HTTP_PROXY = "http://localhost:3128"
PROXY = "http://localhost:3128"
http-proxy = "http://localhost:3128"
http_proxy = "http://localhost:3128"
https-proxy = "https://localhost:3128/"
https_proxy = "https://localhost:3128"
proxy = "http://localhost:3128/"

I know some variables are unneccessary but I'm not sure which is using what.


After looking at all of the answers, the one that helped me was providing proxy values in-line with the install command. One of my frustrations was adding the domain to my username. This is not needed. I used the following example to install a specific version of Angular:

npm install -g @angular/[email protected] --proxy "http://username:password@proxy_server:proxy_port" --registry http://registry.npmjs.org

I lost a day trying to make this work. Worked with this steps.

I opened Fiddler and checked the option Rules > Automatically Autenticate.

After, search for file .npmrc, usually in c:\users\ and used it as configuration:

registry=https://registry.npmjs.org/
proxy=http://username:[email protected]:8888
https-proxy=http://username:[email protected]:8888
http-proxy=http://username:[email protected]:8888
strict-ssl=false
ca=null

Hope help someone!


If in case you are using ubuntu trusty 14.0 then search for Network and select Network Proxy and make it none. Now proxy may still be set in system environment variables. check

env|grep -i proxy

you may get output as

http_proxy=http://192.168.X.X:8080/
ftp_proxy=ftp://192.168.X.X:8080/
socks_proxy=socks://192.168.X.X:8080/
https_proxy=https://192.168.X.X:8080/

unset these environment variable as:

unset(http_proxy)

and in this way unset all. Now run npm install ensuring user must have permission to make node_modules folder where you are installing module.


I have faced similar issue and none of the above solution worked as I was in protected network.

To overcome this, I have installed "Fiddler" tool from Telerik, after installation start Fiddler and start installation of Protractor again.

Hope this will resolve your issue.

Thanks.


An important point to remember is if you're behind a corporate firewall and you get you're corporate proxy settings from a .pac file, then be sure to use the value for global proxy.