Skip to main content
dns/promises - Node documentation

Usage in Deno

import * as mod from "node:dns/promises";

The dns.promises API provides an alternative set of asynchronous DNS methods that return Promise objects rather than using callbacks. The API is accessible via import { promises as dnsPromises } from 'node:dns' or import dnsPromises from 'node:dns/promises'.

Classes

Functions

f
getDefaultResultOrder

Get the default value for verbatim in lookup and dnsPromises.lookup().The value could be:

f
getServers

Returns an array of IP address strings, formatted according to RFC 5952,that are currently configured for DNS resolution. A string will include a portsection if a custom port is used.

f
lookup

Resolves a host name (e.g. 'nodejs.org') into the first found A (IPv4) orAAAA (IPv6) record. All option properties are optional. If options is aninteger, then it must be 4 or 6 – if options is not provided, then IPv4and IPv6 addresses are both returned if found.

f
lookupService

Resolves the given address and port into a host name and service usingthe operating system's underlying getnameinfo implementation.

f
resolve

Uses the DNS protocol to resolve a host name (e.g. 'nodejs.org') into an arrayof the resource records. When successful, the Promise is resolved with anarray of resource records. The type and structure of individual results varybased on rrtype:

f
resolve4

Uses the DNS protocol to resolve IPv4 addresses (A records) for the hostname. On success, the Promise is resolved with an array of IPv4addresses (e.g. ['74.125.79.104', '74.125.79.105', '74.125.79.106']).

f
resolve6

Uses the DNS protocol to resolve IPv6 addresses (AAAA records) for the hostname. On success, the Promise is resolved with an array of IPv6addresses.

f
resolveAny

Uses the DNS protocol to resolve all records (also known as ANY or * query).On success, the Promise is resolved with an array containing various types ofrecords. Each object has a property type that indicates the type of thecurrent record. And depending on the type, additional properties will bepresent on the object:

f
resolveCaa

Uses the DNS protocol to resolve CAA records for the hostname. On success,the Promise is resolved with an array of objects containing availablecertification authority authorization records available for the hostname (e.g. [{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]).

f
resolveCname

Uses the DNS protocol to resolve CNAME records for the hostname. On success,the Promise is resolved with an array of canonical name records available forthe hostname (e.g. ['bar.example.com']).

f
resolveMx

Uses the DNS protocol to resolve mail exchange records (MX records) for the hostname. On success, the Promise is resolved with an array of objectscontaining both a priority and exchange property (e.g.[{priority: 10, exchange: 'mx.example.com'}, ...]).

f
resolveNaptr

Uses the DNS protocol to resolve regular expression-based records (NAPTR records) for the hostname. On success, the Promise is resolved with an arrayof objects with the following properties:

f
resolveNs

Uses the DNS protocol to resolve name server records (NS records) for the hostname. On success, the Promise is resolved with an array of name serverrecords available for hostname (e.g.['ns1.example.com', 'ns2.example.com']).

f
resolvePtr

Uses the DNS protocol to resolve pointer records (PTR records) for the hostname. On success, the Promise is resolved with an array of stringscontaining the reply records.

f
resolveSoa

Uses the DNS protocol to resolve a start of authority record (SOA record) forthe hostname. On success, the Promise is resolved with an object with thefollowing properties:

f
resolveSrv

Uses the DNS protocol to resolve service records (SRV records) for the hostname. On success, the Promise is resolved with an array of objects withthe following properties:

f
resolveTxt

Uses the DNS protocol to resolve text queries (TXT records) for the hostname. On success, the Promise is resolved with a two-dimensional arrayof the text records available for hostname (e.g.[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]). Each sub-array contains TXT chunks ofone record. Depending on the use case, these could be either joined together ortreated separately.

f
reverse

Performs a reverse DNS query that resolves an IPv4 or IPv6 address to anarray of host names.

f
setDefaultResultOrder

Set the default value of order in dns.lookup() and [lookup](../.././dns/promises/~/lookup). The value could be:

f
setServers

Sets the IP address and port of servers to be used when performing DNSresolution. The servers argument is an array of RFC 5952 formattedaddresses. If the port is the IANA default DNS port (53) it can be omitted.

Variables

v
ADDRGETNETWORKPARAMS
No documentation available
v
BADFAMILY
No documentation available
v
BADFLAGS
No documentation available
v
BADHINTS
No documentation available
v
BADNAME
No documentation available
v
BADQUERY
No documentation available
v
BADRESP
No documentation available
v
BADSTR
No documentation available
v
CANCELLED
No documentation available
v
CONNREFUSED
No documentation available
v
DESTRUCTION
No documentation available
v
EOF
No documentation available
v
FILE
No documentation available
v
FORMERR
No documentation available
v
LOADIPHLPAPI
No documentation available
v
NODATA
No documentation available
v
NOMEM
No documentation available
v
NONAME
No documentation available
v
NOTFOUND
No documentation available
v
NOTIMP
No documentation available
v
NOTINITIALIZED
No documentation available
v
REFUSED
No documentation available
v
SERVFAIL
No documentation available
v
TIMEOUT
No documentation available