ECONNREFUSED When Trying to Install Anything with NPM

lukeslytalker picture lukeslytalker · Apr 27, 2015 · Viewed 8.6k times · Source

I'm trying to learn Nodejs, but every time I try installing modules from NodeSchool; specifically "how-to-node" & "learnyounode". I'm getting "ECONNREFUSED" when trying to run anything. Can anyone shed a little light as to why I keep getting this? BTW it happens if I run normally or sudo.

I'm assuming it's something to do with proxy settings, but I'm not sure how to fix it. From all the tutes I've read and videos I've watched I appear to be following the instructions correctly.

bu2@pdouxdbu2:~$ npm install -g how-to-node
npm ERR! Error: connect ECONNREFUSED
npm ERR!     at errnoException (net.js:905:11)
npm ERR!     at Object.afterConnect [as oncomplete] (net.js:896:19)
npm ERR!  { [Error: connect ECONNREFUSED]
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect' }
npm ERR! 
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! System Linux 3.11.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "how-to-node"
npm ERR! cwd /home/bu2
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! syscall connect
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! stack Error: connect ECONNREFUSED
npm ERR! stack     at errnoException (net.js:905:11)
npm ERR! stack     at Object.afterConnect [as oncomplete] (net.js:896:19)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/bu2/npm-debug.log
npm ERR! not ok code 0
bu2@pdouxdbu2:~$ sudo npm -g install how-to-node
[sudo] password for bu2: 
npm ERR! Error: connect ECONNREFUSED
npm ERR!     at errnoException (net.js:905:11)
npm ERR!     at Object.afterConnect [as oncomplete] (net.js:896:19)
npm ERR!  { [Error: connect ECONNREFUSED]
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect' }
npm ERR! 
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! System Linux 3.11.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "-g" "install" "how-to-node"
npm ERR! cwd /home/bu2
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! syscall connect
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! stack Error: connect ECONNREFUSED
npm ERR! stack     at errnoException (net.js:905:11)
npm ERR! stack     at Object.afterConnect [as oncomplete] (net.js:896:19)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/bu2/npm-debug.log
npm ERR! not ok code 0
bu2@pdouxdbu2:~$

Answer

Aadhii picture Aadhii · Apr 12, 2017

npm config set proxy http://:proxyaddress:portnumber npm config set https-proxy http://proxyaddress:portnumber first run these two commands and then install. it works.