What Is a CNAME Record?

A CNAME says 'this name is really that name'. It is the right record for www and for hosted platforms, and the wrong record for the bare domain, which is where most people try to put it.

What Is a CNAME Record? — Troiana insight cover

In short

A CNAME (canonical name) record is a DNS entry that makes one hostname an alias for another, so that www.example.com can point at example.com, or shop.example.com can point at a hosting platform's address, and follow it if that address changes. Use a CNAME when the destination is a name rather than a fixed IP, which is the case for most hosted services. It cannot be used on the bare domain because a CNAME forbids other records at the same name; use an A record or your DNS provider's ALIAS or ANAME feature there instead.

What it does

DNS records map names to things. An A record maps a name to an IPv4 address: example.com is at 203.0.113.10. A CNAME record maps a name to another name: www.example.com is really example.com, go and look that up instead. The resolver follows the alias, finds the A record at the destination, and connects there.

The practical effect is indirection. If the destination's address changes, every CNAME pointing at it follows automatically. That is why hosted platforms tell you to set a CNAME to something like yoursite.hostingplatform.net: they can move their servers, change IPs, add load balancing, and your domain keeps working because it points at a name they control rather than an address they would have to ask you to update.

When to use a CNAME rather than an A record

The destination is a service, not a server you control. Netlify, Vercel, Shopify, Webflow, Squarespace, GitHub Pages, HubSpot, most email marketing tools for tracking domains, and CDNs all provide a hostname to CNAME to. Use it. An A record to whatever IP that hostname resolves to today will break when they change it.

A subdomain should follow the main domain. www pointing at the root is the classic case, so the root's address is maintained in one place.

You are verifying or delegating a subdomain to a third party, such as a status page or a support portal on a subdomain.

Use an A record when you have a fixed IP address for a server you run, or on the root domain, where a CNAME is not permitted.

Why the root domain cannot be a CNAME

The DNS specification says that if a name has a CNAME, it can have no other records. The root of a domain, the bare example.com, must carry other records: the NS records that say which nameservers are authoritative, the SOA record, and usually MX records for email and TXT records for verification and email authentication. A CNAME there would forbid all of them, so it is invalid, and most DNS providers refuse to create one. Those that allow it are breaking the rule, and the usual result is email that stops working.

What to use on the root instead

An A record to a fixed IP, if the host provides one. Many do, specifically for this reason.

ALIAS, ANAME or CNAME flattening. Most modern DNS providers, including Cloudflare, Route 53, DNSimple and DNS Made Easy, offer a record type that behaves like a CNAME at the root: you give it a hostname, and the provider resolves it and serves the resulting A record to queries, keeping the other root records intact. The names vary; the function is the same. This is the correct answer for a root domain on a hosted platform.

A redirect from the root to www, with www as a normal CNAME. Older pattern, still valid; the root then only needs an A record to something that redirects, which many registrars provide.

Common uses

  • www to the root domain or to a platform hostname.
  • shop, blog, app, docs, status, help, mail and similar subdomains to the respective hosted services.
  • Email tracking and sending domains for marketing tools, such as email.example.com to the tool's hostname.
  • CDN and asset domains, such as cdn.example.com to the CDN's hostname.
  • DKIM selectors for some email providers, which use CNAMEs to delegate key management.

Each is a case of pointing at a name someone else maintains.

The mistakes

A CNAME on the root. Covered above; refuse it, use ALIAS or an A record.

A CNAME alongside other records at the same name. Not allowed. If a subdomain needs both a website and its own MX records, use an A record for the site.

A CNAME chain. A CNAME pointing at a name that is itself a CNAME, and so on. Permitted, but each hop is another lookup and a slower first connection; keep chains short and avoid loops.

Pointing at an IP. A CNAME's target must be a hostname. CNAME 203.0.113.10 is invalid.

Forgetting the trailing dot. In raw zone files, example.com without a trailing dot is interpreted as relative and becomes example.com.example.com. Provider interfaces usually handle this; a manual zone file does not.

Expecting an instant change. A CNAME, like every record, is cached for its TTL; lower the TTL before changing it.

Losing the record in a migration. When moving DNS providers, every CNAME must be recreated, including the ones for email tools and verification that nobody remembers adding.

Checking a CNAME

dig www.example.com CNAME or an online DNS lookup shows what the name aliases to and what that resolves to. If a hosted platform reports that your domain is not configured, this is the first check: the CNAME exists, points at exactly the hostname the platform specified, and has propagated.

CNAMEs are one of a handful of records that make up a site's domain and hosting setup. If a platform's connection instructions are not working and the record looks right, book a call; it is usually a root-domain or a propagation issue.

Common questions

What is the difference between a CNAME and an A record?

An A record points a name directly at an IPv4 address. A CNAME points a name at another name, which is then resolved, so the alias follows any change to the destination. Use an A record for a fixed IP you control; use a CNAME for hosted services that give you a hostname, and for www pointing at the root.

Can I use a CNAME on my root domain?

No. A CNAME forbids other records at the same name, and the root must carry NS, SOA and usually MX and TXT records. Use an A record if the host provides a fixed IP, or your DNS provider's ALIAS, ANAME or CNAME-flattening feature, which behaves like a CNAME at the root while keeping the other records.

What is CNAME flattening?

A DNS provider feature, also called ALIAS or ANAME, that lets the root domain behave as if it had a CNAME: the provider resolves the target hostname itself and answers queries with the resulting A record, so the root's other records stay valid. Cloudflare, Route 53 and most modern providers support it under one name or another.

How long does a CNAME record take to work?

As long as the record's TTL, since resolvers cache the previous answer. A new CNAME with no previous record at that name usually works within minutes; changing an existing one takes up to the old TTL. Lower the TTL in advance for planned changes, and verify with a DNS lookup tool that the authoritative servers return the new value.

Why does my hosting platform say my CNAME is not set up?

Usually because the record is missing, points at a slightly different hostname than the platform specified, has not propagated yet, or was created on the root domain where a CNAME is invalid and the provider silently rejected it. Check the exact target with a DNS lookup, wait out the TTL, and use ALIAS or an A record for the root.

Have something worth building right?