A Record vs CNAME: Which to Use
- Written by ZonWhois Editorial Team
- Published on
- In Dns Records
Use an A record when you have an IPv4 address to point a name at. Use a CNAME when a name should simply follow another name, so it keeps working if that name's address changes. A CNAME must be the only record on its name, so it cannot sit at the zone root, where SOA and NS records already exist.
Section of: DNS Records Explained: Types and Examples
An A record and a CNAME both make a name resolve, but they do it differently, and mixing them up is a common reason DNS changes fail. For the overview of every type, see DNS records explained; the full single-record pages are DNS A record and DNS CNAME record.
The one-sentence difference
An A record answers “what is the address of this name?” A CNAME answers “this name is just another name for that one.” The first ends the lookup; the second sends the resolver on to the target.
www.example.com. 3600 IN A 203.0.113.10
shop.example.com. 3600 IN CNAME stores.example.net.
Comparison
| A record | CNAME record | |
|---|---|---|
| Points to | An IPv4 address | Another domain name |
| Other records on the same name | Allowed | Not allowed |
| At the zone root | Allowed | Not under the base rules |
| If the target’s address changes | You update the record | The alias follows the target |
| Lookup steps | One | At least one more |
For IPv6 the equivalent of the A record is the AAAA record.
Rules that decide it
- A CNAME must be alone. RFC 1034 says that if a CNAME is present at a node, no other data should be present. If a name has an MX or TXT record, it cannot also be a CNAME.
- One target only. RFC 2181 says there may be only one canonical name for any one alias.
- Mail and nameserver targets must be real hosts. RFC 2181 says the target of an NS or MX record must not be an alias.
- No CNAME at the root. The zone root holds the SOA and NS records, so a plain CNAME cannot go there.
- Records in a set share a TTL. RFC 2181 says the TTLs of all records in a set must be the same, which is why two A records for one name cannot have different TTLs.
How to choose
- The service gave you an IP address. Use an A record (and AAAA if it also gave an IPv6 address).
- The service gave you a hostname. Use a CNAME, on a subdomain such as www.
- You need the bare domain to point at a hostname. A plain CNAME will not do; ask your DNS provider whether it offers flattening or an alias-style record. Cloudflare, for example, documents CNAME flattening.
- The name also needs mail. Mail records and a CNAME cannot share a name, so use an A record for that name or move the alias to a subdomain.
- You use a provider’s proxy. Cloudflare says the final record must point to a hostname with a valid IP address and that queries for other record types on the same name are not supported.
Common mistakes
- Adding a CNAME to a name that already has a TXT or MX record, then getting a conflict error.
- Pointing a CNAME at an IP address. A CNAME target is a name, not an address.
- Copying a target with a stray space or a missing final dot.
- Pointing a mail record at an alias.
Check what you have
Use the DNS lookup tool to ask for the A and CNAME of a name and see which one exists. If a service asks for a host and a port rather than an address, it wants an SRV record instead. If you are using wildcards, see wildcard DNS records for how a wildcard interacts with both.
Worked example: moving a site to a new service
Say www.example.com currently has an A record to an old server, and your new service gives you a hostname instead of an address.
- Look up www.example.com and note the current record and its TTL.
- Delete the A record and add a CNAME with the new hostname as the target. Many providers refuse to add the CNAME while the A record exists, which is the “no other data” rule at work.
- Wait at least the old TTL, then look the name up again to confirm it now returns the CNAME and the target’s address.
Lowering the TTL a day before the change shortens the window in which some resolvers still hold the old answer.
Record check: claims compared with the cited IETF and Cloudflare documents on 2026-11-18; see the editorial policy.
| Feature | A record | CNAME record |
|---|---|---|
| Points to | An IPv4 address | Another domain name |
| Other records on the same name | Allowed | Not allowed: no other data should be present |
| At the zone root | Allowed | Not under the base rules |
| If the target's address changes | You update the record | The alias follows the target |
| Lookup steps | One | At least one more, to resolve the target |
Frequently asked questions
What is the difference between an A record and a CNAME?
An A record maps a name directly to an IPv4 address. A CNAME maps a name to another name, and the resolver restarts the lookup there. Choose the A record when you have an address and the CNAME when you want one name to follow another.
Can I use both an A record and a CNAME on the same name?
No. RFC 1034 says that if a CNAME is present at a node, no other data should be present, so a CNAME and an A record on the same name conflict. Most DNS providers refuse the second record. Use one or the other, or put them on different names.
Why can't I use a CNAME on my root domain?
The root of a zone already holds SOA and NS records, and a CNAME must be alone on its name. Some providers add flattening or alias features that act like a CNAME at the root; Cloudflare documents CNAME flattening. Check your own provider's documentation.
Which one is faster?
An A record answers in one lookup. A CNAME adds a step because the resolver then looks up the target. Caching hides most of the difference, so choose on how you want the name to behave, not on a few milliseconds.
Should www be a CNAME or an A record?
Either works. If the service you use gives you a hostname, use a CNAME so the service can change addresses. If it gives you an IP address, use an A record. Always follow the exact record type the service tells you to create.
Sources and further reading
- RFC 1034: Domain names, concepts and facilities (rfc-editor.org)
- RFC 2181: Clarifications to the DNS specification (rfc-editor.org)
- Cloudflare: DNS record types (developers.cloudflare.com)
You might also like
- DNS Records Explained: Types and Examples
What DNS records are, how a lookup finds them, and what A, AAAA, CNAME, MX, TXT, NS and SOA records do, with examples and common mistakes.
- DNS A Record Explained
A DNS A record maps a name to an IPv4 address. See its fields, example records, how multiple A records behave, TTL, and how to troubleshoot.
- DNS AAAA Record: IPv6 Explained
A DNS AAAA record maps a name to an IPv6 address. See the format, how it differs from an A record, when to add one, and how to test it.
- DNS CNAME Record Explained
A DNS CNAME record makes one name an alias of another. Learn the rules, why it cannot sit at the root, CNAME vs A record, and how to fix conflicts.
- DNS MX Record Explained
A DNS MX record names the mail exchange for a domain and a priority number. Learn how lower values win, why MX cannot be an IP, and null MX.
- DNS TXT Record Explained
A DNS TXT record stores text for a name. Learn the format, string length rules, SPF, DKIM and DMARC syntax pointers, and how to add and check one.