DomainLens

Aprender

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.

Revisa tu sitio antes de corregir

Ejecuta una auditoría nueva en DomainLens y usa el informe como lista de prioridades.

Ejecutar auditoría SEO gratis

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.

SituationUseWhy
Your own server, fixed IPAYou control the address; no indirection needed
SaaS or CDN endpointCNAMEThe provider can move without breaking you
Root domain to a serviceALIAS / flatteningA CNAME is not allowed at the apex
www pointing at the rootCNAMEOne place to change the address
Mail server hostnameAMX 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.

The conflict, and what providers do instead
; 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.

Compruébalo en tu propio sitio

Recursos relacionados