CNAME Records: Aliases and Their One Strict Rule

Beginner⏱ 4 min readUpdated October 13, 2026

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.

A CNAME against a direct A recordwww.example.comCNAMEexample.comA93.184.216.34example.comA93.184.216.34
A CNAME adds one more lookup before the address is found.

How a resolver follows it

  1. A browser asks for the A record of www.example.com.
  2. The resolver finds a CNAME there instead, pointing to example.netlify.app.
  3. It repeats the lookup for example.netlify.app and gets its A record.
  4. It returns both — the CNAME and the address — and caches each for its own TTL.
Note: The target can be a CNAME too. Every extra hop is another lookup, and resolvers give up after a chain of about 8–16, so keep chains short. A CNAME pointing back at itself, directly or through others, makes the name unresolvable.

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.com must 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.com and 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

SituationUseWhy
www → hosting platformCNAMEThe platform can change addresses without you editing DNS.
Apex (example.com) → hosting platformA/AAAA · ALIASThe apex cannot be a CNAME.
Subdomain → SaaS (help desk, shop, status page)CNAMEThat is what the SaaS expects and verifies.
Mail server name in an MX recordA/AAAAMX targets must not be CNAMEs.
DKIM key hosted by your mail providerCNAMEAllowed at selector._domainkey; the provider can rotate keys for you.
_acme-challenge delegated to another DNSCNAMELets 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.

Watch out: When you close a hosted service, delete the CNAME first, then the account. Subdomain takeover explains how attackers find these and how to audit yours.

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
Tip: If +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.

Try it on your domain

See the theory in practice — run a CNAME Lookup for your own domain.