soasme
soasme

Reputation: 392

NPM Cannot Work! "Error: ECONNREFUSED, Could not contact DNS servers"

When I type "npm install express",It show these tips.

soasme@ubuntu:~/Desktop/nodeex$ npm install express
npm ERR! Error: ECONNREFUSED, Could not contact DNS servers
npm ERR!     at IOWatcher.callback (dns.js:74:15)
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Linux 2.6.38-8-generic
npm ERR! command "node" "/usr/local/bin/npm" "install" "express"
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/soasme/Desktop/nodeex/npm-debug.log
npm not ok

Is there any thing can do help to it? I was confused about the "DNS server". Is this means I cannot resolve the url of update? The log file is written belows:

info it worked if it ends with ok
verbose cli [ 'node', '/usr/local/bin/npm', 'install', 'express' ]
info using [email protected]
info using [email protected]
verbose config file /home/soasme/.npmrc
verbose config file /usr/local/etc/npmrc
verbose into /home/soasme/Desktop/nodeex [ 'express' ]
verbose cache add [ 'express', null ]
info addNamed [ 'express', '' ]
verbose addNamed [ null, '' ]
verbose GET express
verbose raw, before any munging express
verbose url resolving [ 'http://registry.npmjs.org/', './express' ]
verbose url resolved http://registry.npmjs.org/express
verbose url parsed { protocol: 'http:',
verbose url parsed   slashes: true,
verbose url parsed   host: 'registry.npmjs.org',
verbose url parsed   hostname: 'registry.npmjs.org',
verbose url parsed   href: 'http://registry.npmjs.org/express',
verbose url parsed   pathname: '/express' }
ERR! Error: ECONNREFUSED, Could not contact DNS servers
ERR!     at IOWatcher.callback (dns.js:74:15)
ERR! Report this *entire* log at:
ERR!     <http://github.com/isaacs/npm/issues>
ERR! or email it to:
ERR!     <[email protected]>
ERR! 
ERR! System Linux 2.6.38-8-generic
ERR! command "node" "/usr/local/bin/npm" "install" "express"
verbose exit [ 11, true ]

Upvotes: 3

Views: 7017

Answers (2)

soasme
soasme

Reputation: 392

vi /etc/resolv.conf, and add a line "nameserver 8.8.8.8". Then it work.

Upvotes: 3

ty4z2008
ty4z2008

Reputation: 351

that default use proxy http://127.0.0.1.8087

so execute:

npm config set proxy null

Upvotes: 3

Related Questions