Skip to main content
node__dns.d.ts - Node documentation

Usage in Deno

```typescript import * as mod from "node:node__dns.d.ts"; ```
The `node:dns` module enables name resolution. For example, use it to look up IP addresses of host names. Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the DNS protocol for lookups. [lookup](.././node__dns.d.ts/~/lookup) uses the operating system facilities to perform name resolution. It may not need to perform any network communication. To perform name resolution the way other applications on the same system do, use [lookup](.././node__dns.d.ts/~/lookup). ```js import dns from 'node:dns'; dns.lookup('example.org', (err, address, family) => { console.log('address: %j family: IPv%s', address, family); }); // address: "93.184.216.34" family: IPv4 ``` All other functions in the `node:dns` module connect to an actual DNS server to perform name resolution. They will always use the network to perform DNS queries. These functions do not use the same set of configuration files used by [lookup](.././node__dns.d.ts/~/lookup) (e.g. `/etc/hosts`). Use these functions to always perform DNS queries, bypassing other name-resolution facilities. ```js import dns from 'node:dns'; dns.resolve4('archive.org', (err, addresses) => { if (err) throw err; console.log(`addresses: ${JSON.stringify(addresses)}`); addresses.forEach((a) => { dns.reverse(a, (err, hostnames) => { if (err) { throw err; } console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`); }); }); }); ``` See the [Implementation considerations section](https://nodejs.org/docs/latest-v22.x/api/dns.html#implementation-considerations) for more information.

Classes

c
promises.Resolver
An independent resolver for DNS requests. Creating a new resolver uses the default server settings. Setting the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetserversservers) does not affect other resolvers: ```js import { promises } from 'node:dns'; const resolver = new promises.Resolver(); resolver.setServers(['4.4.4.4']); // This request will use the server at 4.4.4.4, independent of global settings. resolver.resolve4('example.org').then((addresses) => { // ... }); // Alternatively, the same code can be written using async-await style. (async function() { const addresses = await resolver.resolve4('example.org'); })(); ``` The following methods from the `dnsPromises` API are available: * `resolver.getServers()` * `resolver.resolve()` * `resolver.resolve4()` * `resolver.resolve6()` * `resolver.resolveAny()` * `resolver.resolveCaa()` * `resolver.resolveCname()` * `resolver.resolveMx()` * `resolver.resolveNaptr()` * `resolver.resolveNs()` * `resolver.resolvePtr()` * `resolver.resolveSoa()` * `resolver.resolveSrv()` * `resolver.resolveTxt()` * `resolver.reverse()` * `resolver.setServers()`
c
Resolver
An independent resolver for DNS requests. Creating a new resolver uses the default server settings. Setting the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnssetserversservers) does not affect other resolvers: ```js import { Resolver } from 'node:dns'; const resolver = new Resolver(); resolver.setServers(['4.4.4.4']); // This request will use the server at 4.4.4.4, independent of global settings. resolver.resolve4('example.org', (err, addresses) => { // ... }); ``` The following methods from the `node:dns` module are available: * `resolver.getServers()` * `resolver.resolve()` * `resolver.resolve4()` * `resolver.resolve6()` * `resolver.resolveAny()` * `resolver.resolveCaa()` * `resolver.resolveCname()` * `resolver.resolveMx()` * `resolver.resolveNaptr()` * `resolver.resolveNs()` * `resolver.resolvePtr()` * `resolver.resolveSoa()` * `resolver.resolveSrv()` * `resolver.resolveTxt()` * `resolver.reverse()` * `resolver.setServers()`

Functions

f
getDefaultResultOrder
Get the default value for `order` in [lookup](.././node__dns.d.ts/~/lookup) and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options). The value could be: * `ipv4first`: for `order` defaulting to `ipv4first`. * `ipv6first`: for `order` defaulting to `ipv6first`. * `verbatim`: for `order` defaulting to `verbatim`.
f
getServers
Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), that are currently configured for DNS resolution. A string will include a port section if a custom port is used. ```js [ '4.4.4.4', '2001:4860:4860::8888', '4.4.4.4:1053', '[2001:4860:4860::8888]:1053', ] ```
f
lookup
Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or AAAA (IPv6) record. All `option` properties are optional. If `options` is an integer, then it must be `4` or `6` – if `options` is `0` or not provided, then IPv4 and IPv6 addresses are both returned if found. With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the properties `address` and `family`. On error, `err` is an `Error` object, where `err.code` is the error code. Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors. `dns.lookup()` does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v22.x/api/dns.html#implementation-considerations) before using `dns.lookup()`. Example usage: ```js import dns from 'node:dns'; const options = { family: 6, hints: dns.ADDRCONFIG | dns.V4MAPPED, }; dns.lookup('example.com', options, (err, address, family) => console.log('address: %j family: IPv%s', address, family)); // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6 // When options.all is true, the result will be an Array. options.all = true; dns.lookup('example.com', options, (err, addresses) => console.log('addresses: %j', addresses)); // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] ``` If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v22.x/api/util.html#utilpromisifyoriginal) ed version, and `all` is not set to `true`, it returns a `Promise` for an `Object` with `address` and `family` properties.
f
lookupService
Resolves the given `address` and `port` into a host name and service using the operating system's underlying `getnameinfo` implementation. If `address` is not a valid IP address, a `TypeError` will be thrown. The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown. On an error, `err` is an [`Error`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-error) object, where `err.code` is the error code. ```js import dns from 'node:dns'; dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { console.log(hostname, service); // Prints: localhost ssh }); ``` If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v22.x/api/util.html#utilpromisifyoriginal) ed version, it returns a `Promise` for an `Object` with `hostname` and `service` properties.
f
promises.getDefaultResultOrder
Get the default value for `verbatim` in [lookup](.././node__dns.d.ts/~/lookup) and [dnsPromises.lookup()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options). The value could be: * `ipv4first`: for `verbatim` defaulting to `false`. * `verbatim`: for `verbatim` defaulting to `true`.
f
promises.getServers
Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), that are currently configured for DNS resolution. A string will include a port section if a custom port is used. ```js [ '4.4.4.4', '2001:4860:4860::8888', '4.4.4.4:1053', '[2001:4860:4860::8888]:1053', ] ```
f
promises.lookup
Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or AAAA (IPv6) record. All `option` properties are optional. If `options` is an integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 and IPv6 addresses are both returned if found. With the `all` option set to `true`, the `Promise` is resolved with `addresses` being an array of objects with the properties `address` and `family`. On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code. Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors. [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options) does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v20.x/api/dns.html#implementation-considerations) before using `dnsPromises.lookup()`. Example usage: ```js import dns from 'node:dns'; const dnsPromises = dns.promises; const options = { family: 6, hints: dns.ADDRCONFIG | dns.V4MAPPED, }; dnsPromises.lookup('example.com', options).then((result) => { console.log('address: %j family: IPv%s', result.address, result.family); // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6 }); // When options.all is true, the result will be an Array. options.all = true; dnsPromises.lookup('example.com', options).then((result) => { console.log('addresses: %j', result); // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] }); ```
f
promises.lookupService
Resolves the given `address` and `port` into a host name and service using the operating system's underlying `getnameinfo` implementation. If `address` is not a valid IP address, a `TypeError` will be thrown. The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown. On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code. ```js import dnsPromises from 'node:dns'; dnsPromises.lookupService('127.0.0.1', 22).then((result) => { console.log(result.hostname, result.service); // Prints: localhost ssh }); ```
f
promises.resolve
Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array of the resource records. When successful, the `Promise` is resolved with an array of resource records. The type and structure of individual results vary based on `rrtype`: On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
f
promises.resolve4
Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv4 addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
f
promises.resolve6
Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv6 addresses.
f
promises.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 of records. Each object has a property `type` that indicates the type of the current record. And depending on the `type`, additional properties will be present on the object: Here is an example of the result object: ```js [ { type: 'A', address: '127.0.0.1', ttl: 299 }, { type: 'CNAME', value: 'example.com' }, { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, { type: 'NS', value: 'ns1.example.com' }, { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, { type: 'SOA', nsname: 'ns1.example.com', hostmaster: 'admin.example.com', serial: 156696742, refresh: 900, retry: 900, expire: 1800, minttl: 60 } ] ```
f
promises.resolveCaa
Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success, the `Promise` is resolved with an array of objects containing available certification authority authorization records available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
f
promises.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 for the `hostname` (e.g. `['bar.example.com']`).
f
promises.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 objects containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
f
promises.resolveNaptr
Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects with the following properties: * `flags` * `service` * `regexp` * `replacement` * `order` * `preference` ```js { flags: 's', service: 'SIP+D2U', regexp: '', replacement: '_sip._udp.example.com', order: 30, preference: 100 } ```
f
promises.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 server records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
f
promises.resolvePtr
Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. On success, the `Promise` is resolved with an array of strings containing the reply records.
f
promises.resolveSoa
Uses the DNS protocol to resolve a start of authority record (`SOA` record) for the `hostname`. On success, the `Promise` is resolved with an object with the following properties: * `nsname` * `hostmaster` * `serial` * `refresh` * `retry` * `expire` * `minttl` ```js { nsname: 'ns.example.com', hostmaster: 'root.example.com', serial: 2013101809, refresh: 10000, retry: 2400, expire: 604800, minttl: 3600 } ```
f
promises.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 with the following properties: * `priority` * `weight` * `port` * `name` ```js { priority: 10, weight: 5, port: 21223, name: 'service.example.com' } ```
f
promises.resolveTxt
Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. On success, the `Promise` is resolved with a two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of one record. Depending on the use case, these could be either joined together or treated separately.
f
promises.reverse
Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names. On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).
f
promises.setDefaultResultOrder
Set the default value of `order` in `dns.lookup()` and `[lookup](.././node__dns.d.ts/~/lookup)`. The value could be: * `ipv4first`: sets default `order` to `ipv4first`. * `ipv6first`: sets default `order` to `ipv6first`. * `verbatim`: sets default `order` to `verbatim`. The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder) have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder). When using [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder) from the main thread won't affect the default dns orders in workers.
f
promises.setServers
Sets the IP address and port of servers to be used when performing DNS resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted addresses. If the port is the IANA default DNS port (53) it can be omitted. ```js dnsPromises.setServers([ '4.4.4.4', '[2001:4860:4860::8888]', '4.4.4.4:1053', '[2001:4860:4860::8888]:1053', ]); ``` An error will be thrown if an invalid address is provided. The `dnsPromises.setServers()` method must not be called while a DNS query is in progress. This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). That is, if attempting to resolve with the first server provided results in a `NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with subsequent servers provided. Fallback DNS servers will only be used if the earlier ones time out or result in some other error.
f
resolve
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array of the resource records. The `callback` function has arguments `(err, records)`. When successful, `records` will be an array of resource records. The type and structure of individual results varies based on `rrtype`: On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-error) object, where `err.code` is one of the `DNS error codes`.
f
resolve4
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
f
resolve6
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv6 addresses.
f
resolveAny
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query). The `ret` argument passed to the `callback` function will be an array containing various types of records. Each object has a property `type` that indicates the type of the current record. And depending on the `type`, additional properties will be present on the object: Here is an example of the `ret` object passed to the callback: ```js [ { type: 'A', address: '127.0.0.1', ttl: 299 }, { type: 'CNAME', value: 'example.com' }, { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, { type: 'NS', value: 'ns1.example.com' }, { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, { type: 'SOA', nsname: 'ns1.example.com', hostmaster: 'admin.example.com', serial: 156696742, refresh: 900, retry: 900, expire: 1800, minttl: 60 } ] ``` DNS server operators may choose not to respond to `ANY` queries. It may be better to call individual methods like [resolve4](.././node__dns.d.ts/~/resolve4), [resolveMx](.././node__dns.d.ts/~/resolveMx), and so on. For more details, see [RFC 8482](https://tools.ietf.org/html/rfc8482).
f
resolveCaa
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve `CAA` records for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of certification authority authorization records available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
f
resolveCname
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`).
f
resolveMx
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of objects containing both a `priority` and `exchange` property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
f
resolveNaptr
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of objects with the following properties: * `flags` * `service` * `regexp` * `replacement` * `order` * `preference` ```js { flags: 's', service: 'SIP+D2U', regexp: '', replacement: '_sip._udp.example.com', order: 30, preference: 100 } ```
f
resolveNs
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`).
f
resolvePtr
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will be an array of strings containing the reply records.
f
resolveSoa
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve a start of authority record (`SOA` record) for the `hostname`. The `address` argument passed to the `callback` function will be an object with the following properties: * `nsname` * `hostmaster` * `serial` * `refresh` * `retry` * `expire` * `minttl` ```js { nsname: 'ns.example.com', hostmaster: 'root.example.com', serial: 2013101809, refresh: 10000, retry: 2400, expire: 604800, minttl: 3600 } ```
f
resolveSrv
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will be an array of objects with the following properties: * `priority` * `weight` * `port` * `name` ```js { priority: 10, weight: 5, port: 21223, name: 'service.example.com' } ```
f
resolveTxt
> [!WARNING] Deno compatibility > The `ttl` option is not supported. Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `records` argument passed to the `callback` function is a two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of one record. Depending on the use case, these could be either joined together or treated separately.
f
reverse
Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names. On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-error) object, where `err.code` is one of the [DNS error codes](https://nodejs.org/docs/latest-v22.x/api/dns.html#error-codes).
f
setDefaultResultOrder
Set the default value of `order` in [lookup](.././node__dns.d.ts/~/lookup) and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnspromiseslookuphostname-options). The value could be: * `ipv4first`: sets default `order` to `ipv4first`. * `ipv6first`: sets default `order` to `ipv6first`. * `verbatim`: sets default `order` to `verbatim`. The default is `verbatim` and [setDefaultResultOrder](.././node__dns.d.ts/~/setDefaultResultOrder) have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--dns-result-orderorder). When using [worker threads](https://nodejs.org/docs/latest-v22.x/api/worker_threads.html), [setDefaultResultOrder](.././node__dns.d.ts/~/setDefaultResultOrder) from the main thread won't affect the default dns orders in workers.
f
setServers
Sets the IP address and port of servers to be used when performing DNS resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted addresses. If the port is the IANA default DNS port (53) it can be omitted. ```js dns.setServers([ '4.4.4.4', '[2001:4860:4860::8888]', '4.4.4.4:1053', '[2001:4860:4860::8888]:1053', ]); ``` An error will be thrown if an invalid address is provided. The `dns.setServers()` method must not be called while a DNS query is in progress. The [setServers](.././node__dns.d.ts/~/setServers) method affects only [resolve](.././node__dns.d.ts/~/resolve), `dns.resolve*()` and [reverse](.././node__dns.d.ts/~/reverse) (and specifically _not_ [lookup](.././node__dns.d.ts/~/lookup)). This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). That is, if attempting to resolve with the first server provided results in a `NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with subsequent servers provided. Fallback DNS servers will only be used if the earlier ones time out or result in some other error.

Interfaces

I
AnyAaaaRecord
No documentation available
I
AnyARecord
No documentation available
I
AnyCnameRecord
No documentation available
I
AnyMxRecord
No documentation available
I
AnyNaptrRecord
No documentation available
I
AnyNsRecord
No documentation available
I
AnyPtrRecord
No documentation available
I
AnySoaRecord
No documentation available
I
AnySrvRecord
No documentation available
I
AnyTxtRecord
No documentation available
I
LookupAddress
No documentation available
I
LookupAllOptions
No documentation available
I
LookupOneOptions
No documentation available
I
LookupOptions
No documentation available
I
MxRecord
No documentation available
I
RecordWithTtl
No documentation available
I
ResolveOptions
No documentation available
I
ResolverOptions
No documentation available
I
ResolveWithTtlOptions
No documentation available
I
SrvRecord
No documentation available

Namespaces

N
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'`.

Type Aliases

T
AnyRecord
No documentation available
T
AnyRecordWithTtl
No documentation available

Variables

v
ADDRCONFIG
Limits returned address types to the types of non-loopback addresses configured on the system. For example, IPv4 addresses are only returned if the current system has at least one IPv4 address configured.
v
ADDRGETNETWORKPARAMS
No documentation available
v
ALL
If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as well as IPv4 mapped IPv6 addresses.
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
promises.ADDRGETNETWORKPARAMS
No documentation available
v
promises.BADFAMILY
No documentation available
v
promises.BADFLAGS
No documentation available
v
promises.BADHINTS
No documentation available
v
promises.BADNAME
No documentation available
v
promises.BADQUERY
No documentation available
v
promises.BADRESP
No documentation available
v
promises.BADSTR
No documentation available
v
promises.CANCELLED
No documentation available
v
promises.CONNREFUSED
No documentation available
v
promises.DESTRUCTION
No documentation available
v
promises.EOF
No documentation available
v
promises.FILE
No documentation available
v
promises.FORMERR
No documentation available
v
promises.LOADIPHLPAPI
No documentation available
v
promises.NODATA
No documentation available
v
promises.NOMEM
No documentation available
v
promises.NONAME
No documentation available
v
promises.NOTFOUND
No documentation available
v
promises.NOTIMP
No documentation available
v
promises.NOTINITIALIZED
No documentation available
v
promises.REFUSED
No documentation available
v
promises.SERVFAIL
No documentation available
v
promises.TIMEOUT
No documentation available
v
REFUSED
No documentation available
v
SERVFAIL
No documentation available
v
TIMEOUT
No documentation available
v
V4MAPPED
If the IPv6 family was specified, but no IPv6 addresses were found, then return IPv4 mapped IPv6 addresses. It is not supported on some operating systems (e.g. FreeBSD 10.1).