Skip to content
Cloudflare Docs

dns

To enable built-in Node.js APIs and polyfills, add the nodejs_compat compatibility flag to your Wrangler configuration file. This also enables nodejs_compat_v2 as long as your compatibility date is 2024-09-23 or later. Learn more about the Node.js compatibility flag and v2.

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

index.js
import dns from "node:dns";
let responese = 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.

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