[ Web Proxy ]
URL:
Viewing: https://developers.cloudflare.com/workers/runtime-apis/nodejs/dns/ [Back]  [Original]

dns Cloudflare Workers docsSkip to content
SearchCtrlKLog in
  1. Home
  2. /Workers
  3. /
  4. /Node.js compatibility
  5. /dns

dns

Last updated Apr 23, 2026Copy as MarkdownView as MarkdownAgent setup

Note

For compatibility dates of 2026-08-04 or later, Workers enables both nodejs_compat and nodejs_compat_v2 by default. These flags are not used for these compatibility dates. Existing projects do not need to remove them when updating their compatibility date. For earlier dates, add nodejs_compat to your Wrangler configuration file to opt in. For instructions to turn off Node.js compatibility, refer to the Node.js compatibility flag.

You can use node:dns for name resolution via DNS over HTTPS using Cloudflare DNS at 1.1.1.1.

index.jsjs
import dns from "node:dns";

let response = await dns.promises.resolve4("cloudflare.com", "NS");
index.tsts
import dns from 'node:dns';

let response = await dns.promises.resolve4('cloudflare.com', 'NS');

All node:dns functions are available, except lookup, lookupService, and resolve which throw "Not implemented" errors when called.

Note

DNS requests will execute a subrequest, counts for your Worker's subrequest limit.

The full node:dns API is documented in the Node.js documentation for node:dns .

PreviousDiagnostics ChannelNextEventEmitter

Was this helpful?

YesNo
Edit pageReport issue
[]

Web Proxy Viewer  |  New URL  |  Original Page