CNAME Records: Aliases and Their One Strict Rule
A CNAME says: this name is another name. It is how you point www or shop at a hosting platform without knowing — or caring — what addresses that platform uses today. It also comes with one rule that explains most CNAME errors.
What a CNAME does
A CNAME (canonical name) record contains a hostname instead of an address. Anyone looking up the alias is sent on to that hostname.
www.example.com. — The alias: the name you own and want to point somewhere.
Point at, tap or tab to a part of the record to see what it does.
How a resolver follows it
- A browser asks for the A record of
www.example.com. - The resolver finds a CNAME there instead, pointing to
example.netlify.app. - It repeats the lookup for
example.netlify.appand gets its A record. - It returns both — the CNAME and the address — and caches each for its own TTL.
The rule: nothing else at that name
A name that has a CNAME cannot have any other record — no TXT, no MX, not even a second CNAME (RFC 1034 §3.6.2, RFC 2181 §10.1). The resolver would not know whether to answer from the alias or from the target.
; invalid — a CNAME cannot share its name with other records
shop.example.com. 3600 IN CNAME shops.myshopify.com.
shop.example.com. 3600 IN TXT "google-site-verification=…"
; invalid — the apex must have SOA and NS, so it cannot be a CNAME
example.com. 3600 IN CNAME example.netlify.app.- The apex cannot be a CNAME.
example.commust carry SOA and NS records, so a CNAME there breaks the rule. Use A/AAAA, or ALIAS/flattening — see A vs CNAME vs ALIAS. - A verification token cannot go on a CNAME'd name. If a service asks for a TXT on
shop.example.comand that name is a CNAME, put the token where the service allows (often_something.shop) or verify another way. - Mail does not mix with CNAMEs. MX targets must not be CNAMEs, and a name with MX records cannot become a CNAME.
- Dashboards that let you save both are not doing you a favour: some resolvers will answer one, some the other.
When to use a CNAME — and when not
| Situation | Use | Why |
|---|---|---|
www → hosting platform | CNAME | The platform can change addresses without you editing DNS. |
Apex (example.com) → hosting platform | A/AAAA · ALIAS | The apex cannot be a CNAME. |
| Subdomain → SaaS (help desk, shop, status page) | CNAME | That is what the SaaS expects and verifies. |
| Mail server name in an MX record | A/AAAA | MX targets must not be CNAMEs. |
| DKIM key hosted by your mail provider | CNAME | Allowed at selector._domainkey; the provider can rotate keys for you. |
_acme-challenge delegated to another DNS | CNAME | Lets certificate validation happen in a zone you automate. |
Dangling CNAMEs and subdomain takeover
A CNAME keeps pointing at its target long after you stop using the service. If the target account is deleted, the name on the platform may become free — and whoever claims it next serves content on your subdomain, with a valid certificate.
Checking a CNAME
A normal lookup shows the whole chain: the alias first, then what it resolves to.
dig www.example.com +short
# example.netlify.app. ← the CNAME
# 203.0.113.80 ← the address it leads to
dig www.example.com CNAME +short # only the alias itself+short shows only the address, there is no CNAME — the name has a direct A record. If it shows the CNAME but no address, the target does not resolve: check the spelling and whether the service still exists.Frequently asked questions
Can I use a CNAME for my root domain?
No — the apex must have SOA and NS records, and a CNAME cannot coexist with them. Use A/AAAA records or your DNS provider's ALIAS/ANAME or CNAME flattening.
Is a CNAME slower than an A record?
It adds one lookup the first time; after that both answers are cached. With a sensible TTL the difference is not noticeable.
Can a CNAME point to another domain?
Yes. That is its main use — pointing your subdomain at a provider's hostname.
Why can't I add a TXT record to my CNAME subdomain?
Because a name with a CNAME cannot have any other record. Put the TXT on another name, or replace the CNAME with A/AAAA records.
See the theory in practice — run a CNAME Lookup for your own domain.
Updated October 13, 2026