Apprendre
CNAME vs A Record: Which to Use and Why Root Domains Are Different
An A record names an address. A CNAME names another name. The choice is about who controls the address — and at the root domain the choice is made for you.
Lancez un audit DomainLens frais et utilisez le rapport comme liste de priorités.
The difference in one sentence each
An A record answers "which IP serves this hostname" with a literal address. A CNAME answers "what is this hostname really called" with another hostname, and the resolver starts over from there.
That extra hop is the whole trade-off. A CNAME costs one more lookup but means you never hardcode an address you do not control — so when your provider moves their infrastructure, nothing in your zone needs to change.
| Situation | Use | Why |
|---|---|---|
| Your own server, fixed IP | A | You control the address; no indirection needed |
| SaaS or CDN endpoint | CNAME | The provider can move without breaking you |
| Root domain to a service | ALIAS / flattening | A CNAME is not allowed at the apex |
| www pointing at the root | CNAME | One place to change the address |
| Mail server hostname | A | MX targets must not be CNAMEs |
Why the root domain cannot take a CNAME
The DNS specification says a name that has a CNAME may have no other records of any type. The root of a zone — the apex, example.com with nothing in front — must carry NS records naming its authoritative servers and an SOA record. Those cannot coexist with a CNAME, so the apex is off limits.
This is not a limitation of your provider, and no configuration screen can lift it. What providers can do is fake it above the protocol level.
; This is invalid and a compliant server will reject it
example.com. 3600 IN CNAME myapp.provider.net.
example.com. 3600 IN NS ns1.provider.net. ; conflict
; ALIAS / ANAME: the provider resolves the target and
; answers with a plain A record, so the apex stays legal
example.com. 300 IN ALIAS myapp.provider.net.
; What the resolver actually receives
example.com. 300 IN A 203.0.113.42
ALIAS, ANAME and CNAME flattening
These are three names for the same trick. The authoritative server resolves the target itself and answers the query with the resulting A or AAAA record, so the client never sees a CNAME and the apex never violates the rule.
The catch is that the flattening happens at your DNS provider, on their schedule. If the target changes address, the flattened answer is stale until the provider re-resolves it — so keep the TTL on these records short, and remember that the behaviour is a provider feature, not a standard you can rely on when moving between them.
The mistakes that actually break things
That last one is the most common by far, and it presents as an SEO problem rather than a DNS one: one hostname works, the other fails outright, and the canonical you carefully configured never gets a chance to matter. Check both forms with the DNS checker before assuming the fault is on the page.
- Pointing an MX record at a CNAME. Mail standards require the target to be a real hostname with an address record, and some servers will refuse.
- Adding a TXT verification record to a name that already has a CNAME — the CNAME wins and the TXT is invisible.
- Chaining CNAMEs several deep. Each hop is another lookup, and some resolvers give up.
- Hardcoding an A record for a CDN endpoint, then wondering why the site broke when the provider renumbered.
- Defining only one of the www and non-www variants, so half your visitors reach nothing.
How DomainLens contributes
DomainLens resolves the hostname it audits and reports the address records it finds, which is how a half-configured www variant surfaces during a normal audit rather than during an outage. For the full set of types see DNS record types , and for choosing one canonical hostname see canonical tag problems .
- Is a CNAME slower than an A record?
- Marginally, because it adds a lookup. In practice the target is almost always cached already, and the operational benefit of not hardcoding an address outweighs a few milliseconds.
- Can I point www at the root with a CNAME?
- Yes, and it is the usual arrangement: www as a CNAME to the apex, with the apex holding the A record. Then the address lives in exactly one place.
- Does ALIAS work the same on every provider?
- The idea is the same but the naming and the refresh behaviour differ. It is a provider feature rather than a DNS standard, so verify it after any migration between providers.
- Which is better for SEO?
- Neither. Google cares that the hostname resolves, not how. Choose on operational grounds.