Skip to content


Fix dns.resolve() with 'PTR' throws Error: Unknown type "PTR" #1038

wants to merge 2 commits into from

3 participants


In API docs, dns.resolve() supports 'PTR' record type, but it throws Error: Unknown type "PTR".


$ node
> require('dns').resolve('', 'PTR', console.log);
Error: Unknown type "PTR"
    at Object.resolve (dns.js:109:11)
    at [object Context]:1:16
    at Interface.<anonymous> (repl.js:171:22)
    at Interface.emit (events.js:64:17)
    at Interface._onLine (readline.js:153:10)
    at Interface._line (readline.js:408:8)
    at Interface._ttyWrite (readline.js:585:14)
    at ReadStream.<anonymous> (readline.js:73:12)
    at ReadStream.emit (events.js:81:20)
    at ReadStream._emitKey (tty_posix.js:307:10)

This change is the same as:

ry commented

test does not pass on my machine. is there another way of testing this.
% ./node test/simple/test-c-ares.js
[ '' ]
[ '' ]

  throw new assert.AssertionError({
AssertionError: 1 == 0
    at /Users/ryan/projects/node/test/simple/test-c-ares.js:64:10
    at dns.js:232:11
    at Object.resolve (dns.js:107:5)
    at Object.<anonymous> (/Users/ryan/projects/node/test/simple/test-c-ares.js:62:5)
    at Module._compile (module.js:407:26)
    at Object..js (module.js:413:10)
    at Module.load (module.js:339:31)
    at Function._load (module.js:298:12)
    at Array.0 (module.js:426:10)
    at EventEmitter._tickCallback (node.js:126:26)

Looks like only one of the NS servers (the first one,, returns 86400 IN PTR localhost.
the others return no records (and there is no NS record for

Of course resolving with libc returns localhost as it is probably listed in /etc/hosts.


I changed the test, please try it again.

ry commented

that fixed it. thanks

@ry ry closed this in d4f82ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 12, 2011
  1. @koichik
Commits on May 15, 2011
  1. @koichik

    Fix test for dns.resolve('PTR')

    koichik committed
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +1 −1  lib/dns.js
  2. +6 −0 test/simple/test-c-ares.js
2  lib/dns.js
@@ -247,7 +247,7 @@ var resolveMap = { A: exports.resolve4,
MX: exports.resolveMx,
TXT: exports.resolveTxt,
SRV: exports.resolveSrv,
- PTR: exports.resolvePtr,
+ PTR: exports.reverse,
NS: exports.resolveNs,
CNAME: exports.resolveCname };
6 test/simple/test-c-ares.js
@@ -58,3 +58,9 @@ dns.lookup('', function(error, result, addressType) {
//assert.equal('string', typeof result);
assert.equal(6, addressType);
+dns.resolve('', 'PTR', function(error, domains) {
+ if (error) throw error;
+ assert.ok(Array.isArray(domains));
Something went wrong with that request. Please try again.