DNS records

CNAME record

A CNAME (canonical name) record makes one name an alias of another. Every lookup for the alias, of any type, is answered by following the target instead. It's how you point www or shop at a service that gives you a host name rather than an address.

Record typeCNAME
Type number5
Used forWebsites
How commonEveryday
Defined inRFC 1034, RFC 1035, RFC 2181

Format

<alias> <ttl> IN CNAME <target name>
FieldWhat it meansAccepted values
NameThe alias. It can't be the domain itself (@).A subdomain such as www, shop or _abc123.verify.
TTLHow long resolvers may cache the alias.Seconds. The target's own records have their own TTLs.
TargetThe name the alias stands for.A full host name, such as shops.myshopify.com. Not an IP address, not a URL with https:// or a path.

Check a CNAME record

Type or paste a record in zone-file form (name, TTL, type, value) or just its value. Each part is explained as you type.

A valid CNAME record.

PartWhat it means
NamewwwA name under the domain. In a dashboard for example.com, “www” means www.example.com.
TTL3600Resolvers may keep this answer for 1 hour before asking again. Changes can take that long to reach everyone.
ClassINInternet. Every record you'll write uses IN.
TypeCNAMEAlias to another name.
Targetexample.com.Every lookup for this name is sent on to this name instead, for every record type. Nothing else can live at a name that has a CNAME.

Examples

www as an alias of the domain

www 3600 IN CNAME example.com.

www.example.com gets whatever addresses example.com has. Change the A record once and both names follow.

Pointing at a hosted service

shop 3600 IN CNAME shops.myshopify.com.

The service can change its servers without you touching your DNS.

Certificate or domain verification

_3f9a.example.com. 3600 IN CNAME _b72c.acm-validations.aws.

Many services verify ownership with an underscore CNAME. Keep it while the service needs to renew.

The CNAME rules

  • A name with a CNAME can't have any other record. Not an MX, not a TXT, not another CNAME. This is the rule people hit most.
  • So a CNAME can't sit at the domain itself (@), because the domain always has SOA and NS records. Use an A record there, or ALIAS / CNAME flattening.
  • MX, NS and SRV records must point at real names, not at CNAMEs.
  • Chains (a CNAME pointing at another CNAME) work, but each step is another lookup. Keep them short; resolvers give up after about 8 to 16 steps.
  • A CNAME redirects DNS lookups, not web traffic. The browser still sends the original name, so the target server must be set up to answer for it (which is why services ask you to add the domain in their dashboard too).

CNAME is not a redirect

Pointing www at example.com with a CNAME doesn't change the address bar. Visitors stay on www.example.com and see whatever the server shows for that name. To send visitors from one address to another, set up an HTTP redirect on the web server or use your DNS host's redirect feature; registrars' "URL forwarding" works that way behind the scenes.

See it on a real domain

Or use the full CNAME lookup.

TTL

3600 is fine for aliases you rarely change. Services that ask for a CNAME usually don't care about its TTL; their own records control how fast their changes spread. How TTL works

Common mistakes

  • Adding a CNAME at the root (@). Most DNS hosts refuse; some accept it and break your email. Use ALIAS or an A record.
  • Adding a CNAME at a name that already has a TXT or MX record, such as a CNAME at mail when mail also has an MX.
  • Pointing a CNAME at an IP address. Use an A record for addresses.
  • Putting https:// or a path in the target. A CNAME target is a bare host name.
  • In a zone file, forgetting the final dot, so shops.myshopify.com becomes shops.myshopify.com.example.com.

At your DNS host

  • Cloudflare: allows a CNAME at the root and flattens it, answering with the target's addresses. Proxied CNAMEs answer with Cloudflare's addresses.
  • Route 53: no CNAME at the root; use an Alias record for AWS targets.
  • GoDaddy: www usually exists as a CNAME to @ already; edit it rather than adding a second one.
  • Type the target as the full name. Dashboards add the trailing dot themselves.

Questions

Why can't I put a CNAME at the root of my domain?

A CNAME can't share its name with any other record, and the root of a domain always has SOA and NS records. Use an A record, or an ALIAS (CNAME flattening) record if your DNS host has one.

Does a CNAME affect email?

Yes, if it's at a name that receives email: a CNAME hides every other record at that name, including MX. That's one more reason not to put a CNAME at the root.

Is a CNAME slower than an A record?

Slightly, the first time: the resolver has to look up the target too. After that both answers are cached for their TTLs, so in practice the difference is milliseconds.

Can a CNAME point to another domain?

Yes. That's the most common use: pointing your subdomain at a service on someone else's domain.

This page is also available as Markdown.

Lemon Domains keeps every domain you own in one place, with expiry reminders, change monitoring and DNS editing from your AI assistant. Get started free