Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

dns.lookup fails when offline on Windows #25338

Closed
@seanpoulter

Description

@seanpoulter

From dns.js, dns.lookup for "localhost" fails, throwing an ENOENT error from getaddrinfo. It's reproducible with the following block:

var dns = require("dns");
dns.lookup("localhost", {"hints":3072}, function(err, ip, addressType) {
  console.log(err, ip, addressType);
})

Running it when connected produces the output:

null '127.0.0.1' 4

but without a network connection:

{ [Error: getaddrinfo ENOENT]
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'getaddrinfo',
  hostname: 'localhost' } undefined undefined

Unfortunately debugging even this simple block with node debug <file> fails trying to connect to port 5858:

>node debug troubleshoot-dns.js
< Debugger listening on port 5858
connecting to port 5858.............There was an internal error in Node's debugger. Please report this bug.
getaddrinfo ENOENT
Error: getaddrinfo ENOENT
    at Object.exports._errnoException (util.js:746:11)
    at errnoException (dns.js:49:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)

One solution is to patch dns.js to replace "localhost" with "127.0.0.1" which produces the expected output, but I think the better solution is to fix the getaddrinfo calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions