Cloudflare 1.1.1.1 (DNS Resolver) Integration Guide
What is 1.1.1.1?
Keyless DoH at cloudflare-dns.com/dns-query. Read Status and Comment, never just response.ok.
GET /dns-query?name=x&type=TXT with accept: application/dns-json. DNS failures are HTTP 200: NXDOMAIN is Status 3 and a DNSSEC failure is Status 2. NOERROR can still mean no records (no Answer key) or a Families block (0.0.0.0 with EDE 16 or 17). Filter Answer by numeric type to drop CNAME hops, and unquote TXT data before comparing. The JSON format has no RFC and had breaking changes in 2026, so use application/dns-message with dns-packet when a wrong parse matters. There is no SLA, so use a timeout and a second resolver on any customer path. For codeAmani this suits checking customer DNS during onboarding, and Android Private DNS suits staff phones on Kenyan projects.
Six 1.1.1.1 primitives
One resolver, reached through different transports and filter levels. Pick by who is asking and what they need to hide or block.
██╗ ██╗ ██╗ ██╗
███║ ███║ ███║ ███║
╚██║ ╚██║ ╚██║ ╚██║
██║ ██║ ██║ ██║
██║██╗██║██╗██║██╗██║
╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝╚═╝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, seeporkbun/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:
- From code: the DNS-over-HTTPS (DoH) API, for example to confirm that a customer added the TXT or CNAME record you asked for.
- On a device or network: set it as the resolver, optionally with Families filtering or with encryption through Android Private DNS.
| 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
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-packetChoosing 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 TXTOn Windows, use nslookup -class=chaos -type=txt id.server 1.1.1.1.
- Stale answer after a record change: clear the entry at https://one.one.one.one/purge-cache/, or wait out the TTL.
- Traceroute to 1.1.1.1 dies at the first hop: Cloudflare documents that some routers
have a hardcoded route for
1.1.1.1. This usually means a router problem, not an outage. whoami.cloudflare.comoutput contains your IP: check before pasting it into a report.
codeAmani notes
- Secrets: there are none. The API is keyless, so no environment variables or Hazina
entries are needed. Never add an
Authorizationheader to these calls. - Production dependency: there is no SLA, and dedicated technical support is limited. Don't let a request path fail because a lookup failed. Give it a timeout, a second resolver, and a "try again later" state. If a product needs a contractual guarantee, use Gateway.
- User input: names often come from customers, for example during custom-domain
onboarding. Validate them before querying (
isQueryableHostname), and only pass the name throughURLSearchParams. - Personal data: queries are logged. Cloudflare doesn't keep source IPs in non-volatile
storage (apart from sampled packets from at most 0.05% of traffic) and deletes resolver
logs within 25 hours, but
queryNameis a logged field and anonymized data is shared with APNIC. Don't put a user ID, email address or phone number in a queried name. - Rate limits: normal use shouldn't hit any. High-rate traffic from one IP and repeated uncacheable answers such as SERVFAIL can be limited, so cache results and back off.
- Workers: outbound
connect()sockets to Cloudflare IP ranges are blocked, so DoT to 1.1.1.1 won't work from a Worker. Usefetchwith DoH, and test it, because this repo has only run these examples on Node. - Kenya-targeted projects: most users are on Android, so Private DNS with
one.one.one.oneis the simplest device hardening, and the setting is on the device, so an app can't set it. Keep this to staff phones and shop devices, and don't make a customer change DNS to complete a checkout. Before recommending it for a network, confirm the serving location by runningcurl https://1.1.1.1/cdn-cgi/traceon that network and readingcolo. - Shared networks: Families suits school or clinic guest Wi-Fi, but it doesn't replace access control. Miscategorized domains are reported through the categorization feedback form.
- AI routing: not applicable, because the resolver makes no model calls.