Error 'tunneling socket' while executing n

2019-01-13 07:34发布

问题:

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?

回答1:

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
    


回答2:

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


回答3:

Following commands may solve your issue:

npm config set proxy false
npm cache clean

It solved my same issue.



回答4:

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.



回答5:

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 http://proxyhostname:proxyport

Hopefully this will solve your problem :)



回答6:

remember to set you username and password if required:

http://USERNAME:passwd@proxyserver.co.uk:8080

Example:

npm config set proxy http://USERNAME:passwd@proxyserver.co.uk:8080


回答7:

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.



回答8:

In my case helped delete .npmrc config file

rm ~/.npmrc


回答9:

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.



回答10:

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:password@127.0.0.1:8888
https-proxy=http://username:password@127.0.0.1:8888
http-proxy=http://username:password@127.0.0.1:8888
strict-ssl=false
ca=null

Hope help someone!



回答11:

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.



回答12:

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.



回答13:

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


回答14:

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/cli@1.7.3 --proxy "http://username:password@proxy_server:proxy_port" --registry http://registry.npmjs.org


回答15:

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!



回答16:

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