npm doesn't work through https_proxy #2050

Closed
chrisdew opened this Issue Jan 17, 2012 · 25 comments
@chrisdew

I'm trying to use npm to install packages on a machine which doesn't have full internet connectivity (we connect to it via a VPN).

For most (non-npm) usages, ssh proxying our office's squid port over ssh to localhost:3129 works fine.

(We use the command 'ssh -R 127.0.0.1:3129:squid_server_ip:3128 root@target_server_ip'.)

As I test, I am successfully able to wget https://www.google.com over this proxy.

The npm docs say it should work: (http://npmjs.org/doc/config.html)

https-proxy
http://npmjs.org/doc/config.htm>Default: the HTTPS_PROXY or https_proxy or HTTP_PROXY or http_proxy environment variables.
Type: url
A proxy to use for outgoing https requests.

I have pasted the console below.

Thanks,

Chris.

P.S. I have also tried export https_proxy=https://127.0.0.1:3129 and export HTTPS_PROXY=https://127.0.0.1:3129, but it doesn't help.

root@server:~# export http_proxy=http://127.0.0.1:3129
root@server:~# export https_proxy=http://127.0.0.1:3129
root@server:~# export HTTP_PROXY=http://127.0.0.1:3129
root@server:~# export HTTPS_PROXY=http://127.0.0.1:3129
root@server:~# wget --no-check-certificate https://www.google.com
--10:32:12--  https://www.google.com/
           => `index.html.2'
Connecting to 127.0.0.1:3129... connected.
WARNING: Certificate verification error for www.google.com: unable to get local issuer certificate
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    [ <=>                                 ] 10,583        --.--K/s             

10:32:12 (164.01 KB/s) - `index.html.2' saved [10583]

root@server:~# npm search forever
npm WARN Building the local index for the first time, please be patient
npm http GET https://registry.npmjs.org/-/all
npm ERR! Error: 3073988288:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:583:
npm ERR! 
npm ERR!     at CleartextStream._puller (tls.js:489:24)
npm ERR!     at CleartextStream._pull (tls.js:420:19)
npm ERR!     at SecurePair.cycle (tls.js:677:20)
npm ERR!     at EncryptedStream.write (tls.js:122:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.emit (events.js:67:17)
npm ERR!     at TCP.onread (net.js:347:14)
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR! 
npm ERR! System Linux 2.6.24-27-server
npm ERR! command "node" "/usr/local/bin/npm" "search" "forever"
npm ERR! cwd /root
npm ERR! node -v v0.6.7
npm ERR! npm -v 1.1.0-beta-10
npm ERR! message 3073988288:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:583:
npm ERR! message 
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/npm-debug.log
npm not ok
root@server:~# cat /root/npm-debug.log 
info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'search', 'forever' ]
info using npm@1.1.0-beta-10
info using node@v0.6.7
verbose config file /root/.npmrc
verbose config file /usr/local/etc/npmrc
verbose config file /usr/local/lib/node_modules/npm/npmrc
WARN Building the local index for the first time, please be patient
verbose raw, before any munging /-/all
verbose url resolving [ 'https://registry.npmjs.org/', './-/all' ]
verbose url resolved https://registry.npmjs.org/-/all
http GET https://registry.npmjs.org/-/all
ERR! Error: 3073988288:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:583:
ERR!     at CleartextStream._puller (tls.js:489:24)
ERR!     at CleartextStream._pull (tls.js:420:19)
ERR!     at SecurePair.cycle (tls.js:677:20)
ERR!     at EncryptedStream.write (tls.js:122:13)
ERR!     at Socket.ondata (stream.js:38:26)
ERR!     at Socket.emit (events.js:67:17)
ERR!     at TCP.onread (net.js:347:14)
ERR! Report this *entire* log at:
ERR!     <http://github.com/isaacs/npm/issues>
ERR! or email it to:
ERR!     <npm-@googlegroups.com>
ERR! 
ERR! System Linux 2.6.24-27-server
ERR! command "node" "/usr/local/bin/npm" "search" "forever"
ERR! cwd /root
ERR! node -v v0.6.7
ERR! npm -v 1.1.0-beta-10
ERR! message 3073988288:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:583:
ERR! message 
verbose exit [ 1, true ]
root@server:~# 
@yoshokatana

I'm also having problems with npm over a proxy. npm get proxy gives me what I have set for HTTP_PROXY in env, and I tried adding "http://" to it (with npm set proxy=http://proxyserver...), but no dice.

@codereflection

Also having this issue. I have https_proxy set in the environment, and tried https-proxy in npm config.. just get the error message from above.

@codereflection

It seems that the work around right now is to redirect to the non-ssl url:

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

@tobr

Same issuse for me.
I also have set HTTP_PROXY and HTTPS_PROXY.

The work around works fine.

@jitheshm

I was able to set my company's proxy and npm install worked

npm config set proxy http://proxy_host:port

@codereflection
@jitheshm

I am running 1.1.16

@abepetrillo

Work around works for me, thanks @codereflection

@MisterY

I just got this issue on CentOs 5. Thanks for the workaround!

@gramakri

Same problem here. Workaround works for me. Using 1.1.62

@eddie-dunn

I get it as well. The workaround works, but is not secure as far as I can tell.

@luk-

I believe this works now but we can reopen if not.

@luk- luk- closed this Mar 13, 2013
@shengmx

same the problem

Using " Command Line Flags"

npm install --proxy myproxy1.mydomain.com:3128 --registry=http://registry.npmjs.org/ socket.io
to get it work without SSL connection.

@maxbane

The workaround fails, though, if you're trying to install a package that has to be fetched from https://github.com instead of the registry.

@EricFortin

Exactly. I am able to clone repository from github over https but I can't install a package through npm. Even more so if the package I want to install is a dependency of another package.

@bowsersenior

Got the same problem on Windows 7 with npm 1.2.25 but the workround does not work. I am on a corporate proxy w/ VPN. Not sure if this issue is related to #2472 ...

@tooxie

@luk- this is still not working.

  • NPM should read the standard $http_proxy and $https_proxy environment variables, this is exactly what they are for.
  • It could fallback to internal config as well if the env vars are not present.
  • A workaround should not be required.
  • The workaround breaks when a git repository needs to be fetched.

Could you please reopen this ticket? Thanks.

@mdurden

Bump

@atuljangra

Thanks for the workaround @codereflection.
I think this issue should be reopened. There is no reason to not use the environment variables.

@othiym23

@atuljangra I'd have to look at the release notes, but more recent versions of npm (most definitely including the versions of npm bundled with Node.js 0.12.0 and io.js 1.1.0+) take advantage of request's support for the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables.

@atuljangra

@othiym23 that could be it. I'm on Ubuntu 14.04 and I've nodejs: 0.10.25 and npm: 1.3.10.
Thanks for the clarification.

@zarvedan

The work around from @codereflection worked for me ! Thanks !

@postelrich

Bumping this issue. Like its been said, setting registry to http works but not when it goes to github or bitbucket for the package. There should be a switch --no-check-certificate like wget.

@hashar

Seems npm 1.4.21 recognizes the environment variables:

$ npm --version
1.4.21
$ npm get registry
https://registry.npmjs.org/
$ export http_proxy="http://webcache"
$ export https_proxy="https://sslproxy"
$ npm get proxy
http://webcache/
$ npm get https-proxy
https://sslproxy/

When hitting HTTPS proxy https://sslproxy/ I am hit with that error. I simply changed the proxy url to http and it worked fine:

- https_proxy=https://sslproxy/
+ https_proxy=http://sslproxy/
                  ^
@danelkhen

👍 @hashar, thanks dude, this worked for me too!

@othiym23 othiym23 added the support label Oct 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment