CNAME record

A CNAME record is a DNS entry that makes one hostname an alias for another, so that app.example.com resolves to whatever your hosting provider's address currently resolves to. It points at a name rather than an IP address, which is why the provider can change servers without you touching your DNS.

What it does and why you would use one

An A record maps a name directly to an IP address. A CNAME maps a name to another name, and the resolver then looks that name up in turn. When you point app.example.com at myapp.web.app with a CNAME, the hosting provider can move between IP addresses, add edge locations or fail over to another region, and your domain follows automatically.

That indirection is the whole value. It is also why almost every managed host — Firebase, Netlify, Vercel, Cloudflare Pages — asks for a CNAME rather than giving you an IP address.

CNAMEs also show up as proof of ownership: providers frequently ask you to create a record such as _acme-challenge.example.com before issuing an SSL certificate, because only someone who controls the domain can create it.

The misconception that costs the most time

A CNAME cannot be set on a bare apex domain at most registrars. example.com with no prefix must carry its NS and SOA records, and the DNS specification does not allow a CNAME to coexist with other records at the same name. So www.example.com can be a CNAME, and example.com cannot.

The workarounds, in the order you should try them:

  1. Use your DNS provider's flattened alias. Cloudflare calls it CNAME flattening, Route 53 calls it an ALIAS record, others call it ANAME. It behaves like a CNAME at the apex and resolves to an address before answering.
  2. Use an A record with the IP addresses your host publishes. This works everywhere but breaks silently if the host ever changes them.
  3. Redirect the apex to www and keep the CNAME on www.

Other things worth knowing

Changes are not instant — the old record stays cached for the length of its TTL, so lowering the TTL a day before a migration saves a lot of waiting. Trailing dots matter in some control panels: myapp.web.app and myapp.web.app. are not the same to every provider. And you cannot have both a CNAME and an MX or TXT record on the same name, which is a common reason mail suddenly stops arriving. Connecting a custom domain walks through the practical sequence.

Frequently asked questions

Why can I not point my root domain at my host with a CNAME?

Because the DNS standard does not allow a CNAME to coexist with other records on the same name, and the root of a domain must carry NS and SOA records. Use your provider’s ALIAS, ANAME or CNAME flattening feature, an A record, or redirect the root to www.

How long does a CNAME change take to work?

Anywhere from a few minutes to a couple of days, depending on the TTL of the record being replaced and on caching by intermediate resolvers. Lowering the TTL to a few minutes a day before making the change is the standard way to keep the switch quick.

Build it yourself

NorthernGo turns a plain-text description into a working web app with a database, login and a live URL. Local AI generation runs on your own GPU, is unlimited, and is free on every plan.

Start building free