You cannot put a CNAME on the root of a domain (example.com, the zone apex): a name with a CNAME may hold no other data, and the apex must hold SOA and NS records. Instead use A and AAAA records, your DNS provider’s ALIAS, ANAME or CNAME-flattening feature, or a www CNAME with an apex redirect. Check the current answer with the CNAME chain tool.
Why the rule exists
RFC 1034 §3.6.2 says: “If a CNAME RR is present at a node, no other data should be present.” RFC 2181 §10.1 makes it firmer: an alias name may carry DNSSEC-related records, “but may have no other data”. A CNAME means every query for that name, whatever its type, is answered by looking at the target name instead.
The apex cannot meet this. RFC 2181 §6.1 states that the NS records for the zone’s origin list its authoritative servers, and that an SOA and NS records are mandatory in every zone. A CNAME there would conflict with them, and with the MX and TXT records that most domains publish at the root (SPF, site verification). Whether a given DNS host rejects the record or accepts it anyway differs, so do not rely on the panel to stop you. See MX points to a CNAME for the mail side effects.
Option 1: A and AAAA records
If your host gives you IP addresses, use them. This is the standard, universal solution and nothing special is needed from the DNS provider. The drawback is that the addresses are fixed in your zone. If the host changes them, your site breaks until you update the records. GitHub’s documentation for Pages shows both ways: an apex domain “is configured with an A, ALIAS, or ANAME record”, while a subdomain such as www uses a CNAME. GitHub also recommends always using a www subdomain, even when you also use an apex domain.
Option 2: ALIAS, ANAME and CNAME flattening
Several DNS providers offer a feature that behaves like a CNAME at the apex. At query time the provider resolves the target itself and returns ordinary address records for your name. The name has A/AAAA answers (and your SOA, NS, MX and TXT are still there), so the standard rule is not broken.
These are provider features, not standard record types, and the details vary:
| Provider | Feature | What its documentation says |
|---|---|---|
| Cloudflare | CNAME flattening | “allows you to use a CNAME record at your zone apex”; Cloudflare resolves the target and returns its addresses |
| Amazon Route 53 | Alias record | Unlike a CNAME you can create an alias at the zone apex, but only to selected AWS resources or to another record of the same type in the hosted zone; Route 53 does not charge for alias queries to AWS resources |
Other providers have their own variants under names such as ALIAS or ANAME. Read their documentation before relying on them. Points to check:
- What targets are allowed. Route 53 aliases only reach specific AWS resources or records in the same hosted zone; a CNAME can point anywhere.
- TTL. For Route 53 aliases to AWS resources you cannot set the TTL; Route 53 uses the resource’s default. Ask other providers how they set it.
- Moving away. The feature disappears when you change DNS host. The new provider may have no equivalent, and then you need A/AAAA records or a
wwwredirect. - Verification records. Cloudflare warns that turning on flattening for all CNAME records can break third-party domain verification, since the verification lookup no longer sees a CNAME.
When you query the apex, the answer looks like a normal A or AAAA record. The DNS lookup will not tell you whether it is flattened; only the provider’s panel does.
Option 3: HTTPS and SVCB records (RFC 9460)
RFC 9460 defines the SVCB and HTTPS record types. Its AliasMode (§2.4.2) has, in its words, the “primary purpose” of allowing “aliasing at the zone apex, where CNAME is not allowed”, and §1.1 lists enabling CNAME-like functionality at a zone apex as a goal. Unlike a CNAME, AliasMode records “do not affect the resolution of other RR types”, so SOA, NS, MX and TXT stay in place.
An example:
example.com. 3600 IN HTTPS 0 cdn.provider.example.
Priority 0 selects AliasMode, and the target is the name to use. The limits matter:
- Only clients that look up HTTPS records follow it. Clients that do not still need ordinary A/AAAA records at the apex, so this record supplements them for now. Check current client support before depending on it.
- Your DNS host must support the HTTPS type and accept it in the panel.
- It covers web traffic (HTTPS); it does not replace a CNAME for mail or other protocols.
Option 4: redirect the apex to www
Keep www.example.com as a CNAME to the provider’s hostname, and give the apex A/AAAA records pointing at a small redirect service that sends visitors to https://www.example.com. GitHub’s Pages documentation describes this pairing: with both names configured correctly, it redirects between the apex and www. Visitors can type either name; the canonical one is www.
How to check your setup
- Run the CNAME chain tool on
www.example.com: it should show the alias and its target. - Run it on the apex: you expect addresses, not a CNAME.
- Use the NS lookup to confirm you are editing at the provider that actually serves your zone. Changes made at a provider that is not authoritative have no effect.
FAQ
My registrar let me add a CNAME at the root. Is that valid?
It may be an ALIAS or flattening feature shown under a CNAME label, or it may be a real CNAME the panel failed to reject. In the second case, the NS, SOA and MX answers at the root can conflict. Look at what the authoritative server returns with the DNS lookup, for types CNAME, A and MX.
Is CNAME flattening a different record on the wire? Yes. Clients receive A and AAAA answers; the provider does the CNAME resolution internally. This is why it does not break the rule in RFC 1034 and RFC 2181, and why a DNS lookup of the apex shows addresses, with SOA, NS, MX and TXT still answering normally alongside them.
Which option should I pick?
Use A/AAAA if your host publishes stable addresses. Use your provider’s alias or flattening feature when the host gives you only a hostname, accepting that it ties you to that DNS provider. Use a www CNAME with an apex redirect when neither is available.
Sources
- RFC 1034, §3.6.2 Aliases and canonical names: https://www.rfc-editor.org/rfc/rfc1034#section-3.6.2
- RFC 2181, §10.1 CNAME resource records, §6.1 Zone authority: https://www.rfc-editor.org/rfc/rfc2181#section-10.1
- RFC 9460, Service Binding and Parameter Specification via the DNS (§1.1, §2.4.2): https://www.rfc-editor.org/rfc/rfc9460
- Cloudflare, CNAME flattening: https://developers.cloudflare.com/dns/cname-flattening/
- Amazon Route 53, Choosing between alias and non-alias records: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html
- GitHub Docs, About custom domains and GitHub Pages: https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages