CNAME vs A Record
A records and CNAME records are the two most common ways to point a domain at something, and they are easy to confuse. An A record maps a name directly to an IP address; a CNAME maps a name to another name. The distinction matters because each has rules and trade-offs that decide which one you should reach for, and using the wrong one can break your apex domain or your email.
Quick answer
Use an A record when you have an IP address to point at, and a CNAME when you want one name to follow another name. A records are required at your root (apex) domain, where CNAMEs are not allowed. CNAMEs shine when you point a subdomain at a provider's hostname and want it to track that provider's IP changes automatically.
What an A record does
An A record maps a hostname directly to an IPv4 address. It is the most fundamental mapping in DNS:
Because it returns the IP directly, an A record involves no extra resolution step. The trade-off is that if the underlying server's IP changes, you must update the record yourself. A records are also the standard way to point your apex domain, where CNAMEs are forbidden.
What a CNAME does
A CNAME record (canonical name) aliases one hostname to another. Instead of an IP, it returns a target name, and the resolver then looks that name up:
This is ideal for pointing a subdomain at a managed service. If the provider changes the IP behind myapp.herokudns.com, your www follows along with no action from you. A CNAME must be the only record on its name, so you cannot add other records, such as MX, alongside it.
Key differences
- Apex restriction. A records work at the root domain (
example.com); CNAMEs are not permitted there because they cannot coexist with the apex SOA and NS records. - Extra lookup. A CNAME adds one resolution step to follow the alias, whereas an A record returns the IP immediately. Caching usually hides this.
- Maintenance. A CNAME tracks its target's IP automatically; an A record must be updated by hand if the IP changes.
- Coexistence. A CNAME must be the only record at its name; an A record can sit beside other record types.
- Chaining. A CNAME may point to another CNAME, but long chains add lookups and are best avoided.
When to use which
Reach for an A record at your apex domain, when you control the server and its IP, or when the name must also carry other record types. Reach for a CNAME on subdomains that point at a third-party service whose IP you do not control, so the mapping stays correct as the provider changes infrastructure.
If you need CNAME-style behaviour at the apex, that is exactly what flattening record types solve; see ALIAS records.
At a glance
| A record | CNAME record | |
|---|---|---|
| Points to | An IPv4 address | Another hostname |
| Allowed at apex | Yes | No |
| Extra lookup | No | Yes |
| Tracks target IP changes | No | Yes |
| Can coexist with other records | Yes | No |