Skip to content

Commit 2876141

Browse files
committed
dns_uv: add localhost hack for windows
1 parent 2513538 commit 2876141

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/dns_uv.js

+9
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ exports.lookup = function(domain, family, callback) {
108108
return {};
109109
}
110110

111+
// Hack required for Windows because Win7 removed the
112+
// localhost entry from c:\WINDOWS\system32\drivers\etc\hosts
113+
// See http://daniel.haxx.se/blog/2011/02/21/localhost-hack-on-windows/
114+
// TODO Remove this once c-ares handles this problem.
115+
if (process.platform == 'win32' && domain == 'localhost') {
116+
callback(null, '127.0.0.1', 4);
117+
return {};
118+
}
119+
111120
var matchedFamily = net.isIP(domain);
112121
if (matchedFamily) {
113122
callback(null, domain, matchedFamily);

0 commit comments

Comments
 (0)