Black Friday: 60% off yearly plans with code BF2026, until November 30. See the deal

Learn

A record vs CNAME: which one should you use?

Use an A record when you know the server IP address, and a CNAME when a hostname owned by someone else should decide the address. An A record maps a name to an IPv4 address; a CNAME maps it to another name and cannot share that name with any other record.

The short answer
  • A holds an IP address. CNAME holds a hostname that is then looked up again.
  • The root domain needs A/AAAA (or an ALIAS feature). Subdomains can use either.
  • A CNAME costs one extra lookup, usually cached, so the speed difference is rarely visible.
Try the dns lookupFree, live, no signup

How do A and CNAME records differ?

A record versus CNAME record
A recordCNAME record
Points toAn IPv4 addressAnother hostname
Allowed at the root domainYesNo (use ALIAS or flattening)
Can share a name with MX, TXT, other recordsYesNo
Follows target IP changes automaticallyNo, you edit the IPYes, the target owner changes it
Extra lookup for the resolverNoYes, one more step
Typical useOwn server, the apexwww, SaaS and CDN subdomains

Constraints from RFC 1034, 3.6.2 and RFC 2181, 10.1.

Which one fits your situation?

You run the server

Use an A record (and AAAA) with your static IP. You control changes.

A platform gives you a hostname

Use a CNAME on a subdomain, so the platform can move servers without telling you.

You need the bare domain

Use A, or ALIAS/flattening if the platform only gives a hostname.

You need mail on the same name

Use A/AAAA. A CNAME blocks MX and TXT on that name.

You run a CDN in front

Follow the CDN docs. Most ask for a CNAME on www and an A or ALIAS at the apex.

You want fewest surprises

Prefer A where you control the IP. Prefer CNAME where someone else does.

What does a typical setup look like?

Apex on A, www on CNAME
example.com.      3600 IN A      192.0.2.10
www.example.com.  3600 IN CNAME  example.com.
shop.example.com. 3600 IN CNAME  stores.example-shop.net.

How do you switch from one to the other?

  1. 01

    Lower the TTL first

    Set the record TTL to 300 seconds a day ahead so the change spreads quickly. See DNS TTL.

  2. 02

    Delete the old record

    A name cannot have a CNAME and an A record at once; remove one before adding the other.

  3. 03

    Add the new record

    Create the A or CNAME with the new value in the same edit session to keep the gap short.

  4. 04

    Check from outside

    Query a public resolver and the authoritative nameserver with the DNS lookup.

What do you check before picking a record type?

  • Does the name need MX or TXT records? Then it cannot be a CNAME
  • Is it the root domain? Then use A/AAAA or a documented alias feature
  • Does the service provide a stable IP? If not, prefer a CNAME to its hostname
  • Will the target ever change without your knowledge? A CNAME follows it, an A record does not

Common questions

Is a CNAME better than an A record?

Neither is better. A CNAME is easier to maintain when a third party manages the IP address, but it adds a lookup and has restrictions. An A record is direct and works anywhere, including the root domain.

Does a CNAME slow down my site?

A CNAME adds one extra DNS lookup the first time a resolver needs it. The result is cached for the TTL, so for most visitors the difference is a few milliseconds at most, and often none.

Can I use a CNAME and an A record on the same name?

No. A CNAME excludes all other data on its name, so you cannot have a CNAME together with an A, MX or TXT record there. Remove one of them.

Should www be a CNAME or an A record?

Either works. A CNAME to the root domain keeps the two names in sync with one IP address to maintain. An A record on www is equally valid and avoids the extra lookup.

Can www be a CNAME while the root domain is an A record?

Yes, and it is the most common layout. The root domain holds an A (and AAAA) record, and www is a CNAME to the root domain, so changing the IP in one place updates both names.

Watch your domains automatically

Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.