CNAME Record Explained: What It Is, How It Works, and Why Root Domains Break It

A CNAME record (canonical name record) says "this hostname is an alias for another hostname." A resolver looks up the alias, gets pointed at the canonical name, and follows that name to an A or AAAA record, which holds the actual IP address.
That covers "what is a CNAME" and "what is CNAME" in two sentences. The rest of this post covers the parts that bite: a CNAME can't share a name with other records, it can't sit on a root domain, and it's the one record your customers add when they connect their own domain to your SaaS.
www.example.com. CNAME edge.yourapp.com.
That's the whole record. www.example.com is the alias. edge.yourapp.com is the canonical name.
For the short glossary version, see the CNAME record glossary entry.
How a CNAME lookup works, step by step
A and AAAA records are the only DNS record types that resolve directly to IP addresses. CNAMEs delegate to other names. So a lookup through a CNAME takes one extra hop:
www.example.com
-> CNAME -> edge.yourapp.com
-> A / AAAA -> 203.0.113.10
The steps:
- The browser asks for
www.example.com. - The resolver finds a CNAME: "that's an alias for
edge.yourapp.com." - The resolver looks up
edge.yourapp.comand finds an A or AAAA record. - The browser connects to that IP.
The upside: when the target's IP changes, the alias follows automatically. Nobody edits the alias side.
CNAME vs A record: which one to use
| CNAME record | A record | |
|---|---|---|
| Points to | Another hostname | An IPv4 address (AAAA for IPv6) |
| Follows the target's IP changes | Yes | No. You update it by hand |
| Can share a name with other records | No | Yes |
| Allowed at the root (apex) | No | Yes |
Rule of thumb: use a CNAME when the target's IP may change. Use an A record when you must sit at the apex and your DNS provider has no flattening.
More detail in the A record glossary entry.
The rules: what a CNAME can't coexist with
A hostname that has a CNAME cannot also have a TXT record, an MX record, or anything else. This comes straight from the standards:
- RFC 1034 section 3.6.2: if a CNAME is present at a name, no other data may be present at that name.
- RFC 2181 section 10.1: a CNAME and any other record type at the same owner name is illegal.
The concrete failure: a CNAME at acme.com would override the MX records. Email stops. Nobody notices until a customer asks why they haven't received an invoice since Tuesday.
Can an MX record point to a CNAME? It shouldn't.
If a TXT record is already on the hostname you're about to alias, the CNAME collides with it. Remove it first.
Can you put a CNAME on a root (apex) domain?
No. The apex is the bare domain, example.com rather than www.example.com. It's the one name in a zone that can never hold a CNAME, because the apex must carry an SOA record and a CNAME can't coexist with anything. That's why pointing a bare domain at a SaaS app is harder than pointing www. Here's why a CNAME at the root is impossible, in more depth.
Three ways around it.
Workaround 1: CNAME flattening
CNAME flattening is a DNS provider feature. The provider stores what looks like a CNAME at the apex, follows the chain itself at query time, and returns A records to the resolver. The customer writes:
janesbakery.com CNAME (flattened) edge.yourapp.com
Their DNS provider then serves the A records of edge.yourapp.com to anyone asking about janesbakery.com. Support varies by provider:
| Provider | Flattening support | Field name |
|---|---|---|
| Cloudflare | Yes | "CNAME Flattening" (auto for apex) |
| Route 53 | Yes | "Alias" target |
| DNSimple | Yes | "ALIAS" record type |
| DNS Made Easy | Yes | "ANAME" record |
| Namecheap | Yes | "ALIAS Record" |
| Google Cloud DNS | No | Use Cloud Load Balancer with anycast IPs |
| GoDaddy | No | n/a |
| Most registrar default DNS | Often no | n/a |
Workaround 2: A records
Where an apex provider disallows CNAME, Domainee offers two anycast A records. The customer adds both at the apex and skips the CNAME entirely.
Workaround 3: use www or another subdomain
The customer points www.theirdomain.com at your edge with a CNAME. Then they set up a redirect from the apex to www at their registrar or DNS host. Boring. Works everywhere.
One limit to know: wildcard domains are not supported at the moment. Each hostname gets its own record.
CNAME records for SaaS custom domains
This is the workhorse of custom-domain SaaS. Your customer adds one CNAME pointing their hostname at your edge, and traffic starts flowing. One record. No registrar tour.
With Domainee, you start with one API call. POST /v1/domains takes a hostname and an originUrl, and returns the CNAME your customer adds:
curl -X POST https://api.domainee.dev/v1/domains \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"hostname": "app.janesbakery.com", "originUrl": "https://yourapp.com"}'
The API is REST at https://api.domainee.dev/v1, JSON only, with Bearer API keys. The domain's status and monitorStatus fields then report where DNS stands. Walk through it end to end in the Domainee quickstart.
The target is visible
The CNAME target is edge.domainee.dev. So the DNS record shows the Domainee name. It isn't hidden, and we won't pretend otherwise. Anyone running a DNS lookup on the hostname can see where it points.
Provider-aware instructions
Your customers don't all use the same DNS provider, and every provider labels its form differently. GET /v1/domains/{id}/instructions detects the DNS provider from public NS records and returns provider-specific steps. Your customer sees the exact record name and value their provider expects.
One-click setup where supported
- Domain Connect on Cloudflare: one-click setup. GoDaddy is not available.
- Scoped token: a Cloudflare or DigitalOcean customer can provide a scoped API token via
POST /v1/domains/{id}/dns/apply. The token is used once and never stored.
Everywhere else, the customer adds the CNAME by hand, using the instructions above.
How to check that a CNAME is working
Start with the free tools. No account needed.
- The free CNAME lookup and generator checks a CNAME record, follows the chain through to the A record behind it, or builds the record your DNS provider expects.
- The free DNS record lookup shows A, AAAA, CNAME, MX, TXT, NS and SOA records for any domain.
The same CNAME check is also a keyless REST endpoint:
curl "https://api.domainee.dev/v1/tools/cname-lookup?host=www.domainee.dev"
There are 18 free public REST endpoints, none needing a key. Limits are 30 requests/min and 500 requests/day per IP.
What Domainee checks for you
Domainee re-checks each domain every 5 minutes, or on demand with POST /v1/domains/{id}/check. The monitorStatus tells you what's going on:
| Monitor state | What it usually means |
|---|---|
dns_not_resolving | The record is missing |
dns_incorrect | The record exists but points at the wrong target |
pending_ssl | DNS is right, the certificate is on its way |
active_ssl | DNS is right and HTTPS is live |
The full list of states is: unknown, dns_not_resolving, dns_incorrect, pending_ssl, active_ssl, ssl_failed, ssl_expired.
SSL is issued by Let's Encrypt on first request, then renewed automatically. It starts once DNS points correctly.
Common CNAME mistakes and fixes
1. Adding a CNAME at the apex. It's invalid by construction. Use www or another subdomain, a provider with flattening, or the two A records.
2. Leaving an old A or TXT record on the same hostname. A CNAME can't coexist with anything else at that name. Delete the old record first, then add the CNAME.
3. Typing the full hostname into a field that appends the zone. Many DNS forms add the domain for you. Enter app, not app.janesbakery.com, or you end up with app.janesbakery.com.janesbakery.com. The generator and the per-provider instructions show the exact record name each provider expects.
4. A CAA record that blocks Let's Encrypt. DNS can be perfect and the certificate still won't issue. Domainee's preflight warns on CAA records that block Let's Encrypt, so you can tell your customer before they wonder why HTTPS is stuck.
5. Expecting it to be live instantly. DNS changes take time to spread. Check the free DNS propagation checker in the free tools before filing a bug.
Ready to try it?
Run your domain through the free CNAME lookup and generator. Then connect your first custom domain with one API call. 20 domains and 100 GB/month are free, forever. After the first 20, it's $0.20/domain/month. A card on file is required before the first domain, and it's charged $0 under the free tier.
FAQ
What is a CNAME record?
A CNAME (canonical name) record says one hostname is an alias for another hostname. A resolver follows it to an A or AAAA record to get the IP address.
What does CNAME stand for?
Canonical name. The target of the record is the canonical, or real, name. The hostname carrying the CNAME is the alias.
What is the difference between a CNAME and an A record?
An A record points a name at an IPv4 address (AAAA for IPv6). A CNAME points a name at another name. CNAMEs follow the target's IP changes, but can't share a name with other records and can't sit at the root.
Can I put a CNAME record on my root domain?
No. The apex must hold an SOA record, and a CNAME can't coexist with anything. Use CNAME flattening if your DNS provider supports it, A records, or a subdomain like www.
Can a CNAME and an MX record exist on the same name?
No. RFC 1034 section 3.6.2 and RFC 2181 section 10.1 both rule it out. A CNAME at the root would override the MX records and break email. An MX record also shouldn't point to a CNAME.
What is CNAME flattening?
CNAME flattening lets a DNS provider publish a CNAME-like record at the apex. The provider follows the chain itself at query time and returns A records to the resolver.
How do I add a CNAME record for a custom domain?
Call POST /v1/domains with hostname and originUrl. The response gives you the CNAME your customer adds. GET /v1/domains/{id}/instructions returns steps specific to their DNS provider. On Cloudflare, one-click Domain Connect setup is available.
Does a CNAME record hide the service I'm pointing to?
No. The CNAME target is public DNS data. With Domainee, the target is edge.domainee.dev, so the record shows the Domainee name.
How do I check whether my CNAME record is working?
Use the free CNAME lookup and generator, or the free DNS record lookup. Neither needs an account. For a connected domain, Domainee re-checks every 5 minutes, or on demand with POST /v1/domains/{id}/check.
Why does my CNAME show dns_incorrect or not resolving?
dns_not_resolving usually means the record is missing. dns_incorrect usually means it points at the wrong target. Check for an old A or TXT record on the same hostname, a zone name appended twice, or a CNAME at the apex. Then run a check again.