npm doesn't work through https_proxy #2050

chrisdew opened this Issue Jan 17, 2012 · 25 comments

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 root@target_server_ip'.)

As I test, I am successfully able to wget over this proxy.

The npm docs say it should work: (

https-proxy>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.



P.S. I have also tried export https_proxy= and export HTTPS_PROXY=, but it doesn't help.

root@server:~# export http_proxy=
root@server:~# export https_proxy=
root@server:~# export HTTP_PROXY=
root@server:~# export HTTPS_PROXY=
root@server:~# wget --no-check-certificate
           => `index.html.2'
Connecting to connected.
WARNING: Certificate verification error for 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
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!     <>
npm ERR! or email it to:
npm ERR!     <>
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 [ '', './-/all' ]
verbose url resolved
http GET
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!     <>
ERR! or email it to:
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 ]

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.


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.


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

npm config set registry=


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

The work around works fine.


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

npm config set proxy http://proxy_host:port


I am running 1.1.16


Work around works for me, thanks @codereflection


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


Same problem here. Workaround works for me. Using 1.1.62


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


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

@luk- luk- closed this Mar 13, 2013

same the problem

Using " Command Line Flags"

npm install --proxy --registry=
to get it work without SSL connection.


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


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.


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 ...


@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.




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


@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.


@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.


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


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.


Seems npm 1.4.21 recognizes the environment variables:

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

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/

👍 @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