Cloudflare 1.1.1.1 (DNS Resolver) Integration Guide

Technology: cloudflare-1-1-1-1 · Category: domains · Last reviewed: 2026-11-04

Source: https://tech-stack.codeamanilabs.org/guide/cloudflare-1-1-1-1

Insight:

1.1.1.1 is Cloudflare's free public DNS resolver, with a keyless DNS-over-HTTPS API at cloudflare-dns.com/dns-query. Reach for it to check records from code and to harden devices, not as a production dependency: it has no SLA and only limited support. DNS failures arrive as HTTP 200 with a non-zero Status, a filtered name returns 0.0.0.0 with Status 0, and the JSON format has no RFC and has already had breaking changes. So read Status and Comment rather than response.ok, and use wireformat when a wrong parse would matter. It answers what a cache sees, not what your nameserver currently holds.

 ██╗   ██╗   ██╗   ██╗
███║  ███║  ███║  ███║
╚██║  ╚██║  ╚██║  ╚██║
 ██║   ██║   ██║   ██║
 ██║██╗██║██╗██║██╗██║
 ╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝

Cloudflare 1.1.1.1 (DNS Resolver) Integration Guide

Focus: query DNS from application code over HTTPS, read the results correctly, and choose the right resolver variant for a device or network. This is the sub-guide to cloudflare/. For DNS records you publish, see porkbun/ for registrar DNS and the Cloudflare DNS docs for zones hosted there.

Overview

1.1.1.1 is a recursive resolver: it looks up names on behalf of clients. It is not authoritative DNS, so it does not host your records. It is free on all plans, needs no account or API key, and Cloudflare operates it in partnership with APNIC.

There are two ways codeAmani uses it:

Variant IPv4 IPv6 DoH endpoint DoT hostname
Standard (unfiltered) 1.1.1.1, 1.0.0.1 2606:4700:4700::1111, ::1001 https://cloudflare-dns.com/dns-query one.one.one.one
Families: malware 1.1.1.2, 1.0.0.2 2606:4700:4700::1112, ::1002 https://security.cloudflare-dns.com/dns-query security.cloudflare-dns.com
Families: malware + adult 1.1.1.3, 1.0.0.3 2606:4700:4700::1113, ::1003 https://family.cloudflare-dns.com/dns-query family.cloudflare-dns.com

Full tables and error codes are in reference/endpoints-and-codes.md.

Should you use it here?

Need Use
Check a DNS record from a server or script 1.1.1.1 DoH
Encrypt DNS on a phone or laptop 1.1.1.1 via Private DNS, or the 1.1.1.1 app
Block malware or adult content on a shared network 1.1.1.1 for Families
Encrypt all device traffic, not only DNS WARP client
An SLA, dedicated support, custom filtering, or analytics Cloudflare Gateway (Zero Trust)
See what your nameserver currently publishes Query the authoritative nameserver (recipe)

Official Documentation

Topic URL
Overview https://developers.cloudflare.com/1.1.1.1/
IP addresses https://developers.cloudflare.com/1.1.1.1/ip-addresses/
DoH API requests https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/
DoH JSON format https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/
DoH wireformat https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-wireformat/
DNS over TLS https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-tls/
Oblivious DoH https://developers.cloudflare.com/1.1.1.1/encryption/oblivious-dns-over-https/
Device setup and Families https://developers.cloudflare.com/1.1.1.1/setup/
Extended DNS error codes https://developers.cloudflare.com/1.1.1.1/infrastructure/extended-dns-error-codes/
Rate limits, network operators https://developers.cloudflare.com/1.1.1.1/infrastructure/network-operators/
SLA and support https://developers.cloudflare.com/1.1.1.1/infrastructure/sla-and-support/
Privacy commitments https://developers.cloudflare.com/1.1.1.1/privacy/public-dns-resolver/
Changelog https://developers.cloudflare.com/1.1.1.1/changelog/

Quickstart: query from code

No key or SDK is needed. The accept header is required: without it, the endpoint answers 400.

curl -H "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=example.com&type=A"
{
  "Status": 0, "TC": false, "RD": true, "RA": true, "AD": true, "CD": false,
  "Question": [{ "name": "example.com", "type": 1 }],
  "Answer": [{ "name": "example.com", "type": 1, "TTL": 121, "data": "172.66.147.243" }]
}

Use the typed client instead of parsing this by hand. examples/doh-json.ts handles the traps below and has no dependencies:

import { resolveDoh } from "./doh-json";

const { outcome, values } = await resolveDoh("_dmarc.codeamanilabs.org", "TXT");
if (outcome === "answer") {
  // values are unquoted and contain TXT records only
}

For binary RFC 8484 queries, use examples/doh-wire.ts:

npm install dns-packet
npm install -D @types/dns-packet

Choosing JSON or wireformat

JSON (application/dns-json) Wireformat (application/dns-message)
Methods GET only GET or POST
Dependencies None dns-packet or similar
Stability No RFC. Cloudflare warns behaviour may change RFC 1035 message format
Use for Scripts, dashboards, non-critical checks Anything where a wrong parse has a cost

Cloudflare recommends wireformat for critical use. Its 2026-07-28 JSON change altered the data format for CAA, HTTPS, SVCB, TLSA and SSHFP records and for DNSSEC algorithm identifiers. Responses could use either format during the rollout, so don't parse those data strings in anything that matters.

Reading responses correctly

These are the mistakes this API invites. Unless marked documented, each was observed against the live resolver on 2026-11-04.

Trap What actually happens Do this
Trusting response.ok DNS failures are HTTP 200: NXDOMAIN is Status: 3, a DNSSEC failure is Status: 2, and ANY is Status: 4 Branch on Status. HTTP errors only mean a bad request or a timeout (400, 413, 415, 504, documented)
Status === 0 means the record exists A name with no record of that type is Status: 0 with no Answer key Treat a missing Answer as NODATA
Treating 0.0.0.0 as a real answer A Families block is Status: 0 with 0.0.0.0 (A) or :: (AAAA) Check Comment and the address. Malware blocks say EDE(16): Censored, adult blocks say EDE(17): Filtered. Neither code is in Cloudflare's EDE table, so also match the sinkhole addresses
Reading Answer[0].data Answer includes CNAME hops, so index 0 may be a hostname Filter by the numeric type you asked for
Comparing TXT values directly TXT data is wrapped in quotes, and long values can be split into several quoted strings Unquote and join first (unquoteTxt in the example)
Using NXDOMAIN to prove a name is free Nonexistent names in the Cloudflare-hosted zones we tested returned NOERROR with no Answer, not NXDOMAIN Treat nxdomain and nodata both as "no record". Never use them to decide a domain is available
Asking for ANY Not supported: documented as NOTIMPL, returned as Status: 4 Query each type
Sending several questions in one request Each DoH request carries one question (documented) Send parallel requests over HTTP/2

Connect a device or network

Android 9 and later (Private DNS): go to Settings > Network & internet > Advanced > Private DNS, choose Private DNS provider hostname, and enter one.one.one.one or one of the Families hostnames. This applies on every network, including cellular. Menu names vary by manufacturer.

Other devices: set the IPv4 and IPv6 addresses from the table above, always in pairs so there is a fallback. Each platform's steps are under Set up.

Browsers: Chrome, Edge, Firefox and Brave all offer Cloudflare in their secure DNS settings. Check the result at https://one.one.one.one/help, where Using DNS over HTTPS (DoH) should show Yes.

IPv6-only networks with NAT64: use the DNS64 addresses 2606:4700:4700::64 and 2606:4700:4700::6400. Only use them on such a network, because a synthesized AAAA record can't carry a valid DNSSEC signature.

To confirm filtering works, open the test pages. https://malware.testcategory.com/ should fail to load on both Families tiers, and https://nudity.testcategory.com/ should fail only on the malware + adult tier.

Encryption options

Protocol Port Reach it at Note
DoH 443 https://cloudflare-dns.com/dns-query Blends in with HTTPS traffic. HTTP/2 is the recommended minimum. TLS 1.2 and 1.3
DoT 853 one.one.one.one, 1.1.1.1 A dedicated port, so networks can block it. Used by Android Private DNS. TLS 1.2 and 1.3
ODoH 443 Target: odoh.cloudflare-dns.com, via a proxy Splits your IP from your query across two parties. RFC 9230 is experimental, and you need a client such as dnscrypt-proxy
Tor - Hidden service See DNS over Tor

Debugging

# Which Cloudflare data center answered?
dig +short CHAOS TXT id.server @1.1.1.1

# Compare resolvers: if only one differs, suspect its cache or the zone's nameservers
dig example.com @1.1.1.1
dig example.com @8.8.8.8

# Read the EDE reason for a failure
dig @1.1.1.1 dnssec-failed.org A

# Test DoT
kdig +tls @1.1.1.1 id.server CH TXT

On Windows, use nslookup -class=chaos -type=txt id.server 1.1.1.1.

codeAmani notes

Official docs: