How to fix Node DNS resolver in Mac

I was working on the node package manager, npm, in Mac OS X and realized I cannot install Zombie.

[code lang=”bash”]kahwee:~ kahwee$ npm install zombie
npm info it worked if it ends with ok
npm info using npm@0.2.11-5
npm info using node@v0.2.6
npm ERR! Error connecting to server http://registry.npmjs.org/zombie
npm ERR! Error: ETIMEOUT, Timeout while contacting DNS servers
npm ERR! at Timer.callback (dns:15:13)
npm ERR! at node.js:773:9
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to npm-@googlegroups.com
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok[/code]

I was hunting around what’s wrong with my DNS servers and I realized that even though Node.js is taking the DNS server settings from resolv.conf, Mac OS X did not have that updated as I would expect. The following is not my nameserver:

[code lang=”bash”]kahwee:~ kahwee$ cat /etc/resolv.conf
#

Mac OS X Notice

#

This file is not used by the host name and address resolution

or the DNS query routing mechanisms used by most processes on

this Mac OS X system.

#

This file is automatically generated.

#
domain Aphrodite
nameserver 192.168.1.254[/code]

So I commented that portion and changed it with nano:

[code lang=”bash”]sudo nano /etc/resolv.conf[/code]

Changed it to and comment the invalid entry:

[code lang=”bash”]kahwee:~ kahwee$ cat /etc/resolv.conf
#

Mac OS X Notice

#

This file is not used by the host name and address resolution

or the DNS query routing mechanisms used by most processes on

this Mac OS X system.

#

This file is automatically generated.

#
#domain Aphrodite
#nameserver 192.168.1.254
nameserver 165.21.100.88
nameserver 165.21.83.88[/code]

And now it works:

[code lang=”bash”]kahwee:~ kahwee$ npm install zombie
npm info it worked if it ends with ok
npm info using npm@0.2.11-5
npm info using node@v0.2.6
npm info fetch http://registry.npmjs.org/zombie/-/zombie-0.8.10.tgz

npm ok[/code]

1 thought on “How to fix Node DNS resolver in Mac”

  1. Any ideas on why node doesn’t use the system stuff/why this file doesn’t get changed whenever you switch networks?

Leave a Reply

Your email address will not be published. Required fields are marked *