What Is a CNAME Record? How It Works and When to Use One
Quick answer
A CNAME (canonical name) record is a DNS record that makes one domain name an alias of another. For example, www.example.com can point to yoursite.hostingplatform.com, and DNS then follows that name to find the IP address. CNAMEs are commonly used to connect www and subdomains to hosted platforms.
How a CNAME record works
A CNAME says, in effect, “this name is really that name”. When a resolver looks up a name that has a CNAME, it switches to the target name and keeps looking until it reaches an A or AAAA record with an IP address.
For example:
www.example.com. CNAME example-store.platform.com.
example-store.platform.com. A 203.0.113.25
A visitor types www.example.com. DNS finds the CNAME, follows it to example-store.platform.com, and returns that name’s IP address. The browser connects to it, and the address bar still shows www.example.com.
The big benefit is that the platform controls the final IP address. If it moves your site to new servers, it updates its own records and your CNAME keeps working without any change from you.
Common uses for CNAME records
- Connecting www to a website builder or host. Many platforms ask you to add a CNAME for
wwwpointing to an address they give you. - Subdomains on other services, such as
shopfor an online store orhelpfor a support centre. See what a subdomain is. - CDNs, which often give you a hostname to point a CNAME at.
- Ownership verification, where a service asks you to create a specific CNAME to prove you control the domain.
- Email authentication, where some email providers publish DKIM keys through CNAMEs you add.
CNAME vs. A record
| CNAME record | A record | |
|---|---|---|
| Points to | Another hostname | An IPv4 address |
| Updates if the server moves | Automatically, through the target | You must edit it yourself |
| Allowed at the root domain | No (except with provider workarounds) | Yes |
| Can share its name with other records | No | Yes |
| Typical use | www and subdomains on hosted platforms | The root domain, or your own server |
If your platform gives you a hostname, use a CNAME. If it gives you an IP address, use an A record.
Rules and limits
CNAMEs come with a few rules from the DNS standards that trip people up:
- A CNAME can’t coexist with other records on the same name. If
wwwhas a CNAME, it can’t also have an A, MX or TXT record. Most DNS dashboards will refuse to save a conflicting record. - No CNAME at the root domain. The bare domain (example.com, often shown as
@) must hold NS and SOA records, so a standard CNAME isn’t allowed there. - MX and NS records shouldn’t point at a CNAME. They should point straight at a hostname with its own address records.
- The target must be a hostname, never an IP address or a URL with
https://or a path.
The root domain workaround
Because many platforms prefer CNAMEs, DNS providers created features that act like a CNAME at the root but answer with an IP address. They go by names such as CNAME flattening, ALIAS or ANAME. They aren’t part of the core standards, and support varies by provider. If yours doesn’t offer one, use the A records your platform provides for the root, or redirect the root to www.
How to add a CNAME record
- Find where your DNS is managed. It’s whichever provider your nameservers point to: often your registrar, host or Cloudflare.
- Open the DNS records page for your domain.
- Add a new record and choose CNAME as the type.
- Enter the name (also called Host). Type only the subdomain part, such as
wwworshop. Most dashboards add your domain automatically. - Enter the target (also called Value or Points to), exactly as your platform gave it, such as
example-store.platform.com. - Remove any conflicting record on the same name, such as an old A record for
www. - Save, then confirm the connection in your platform’s dashboard.
New records usually work within minutes. If you changed an existing record, the old answer can stay in caches until its TTL expires; see DNS propagation.
Troubleshooting
- “Record conflicts with another record”: delete the other record on that name first.
- The domain shows twice, like www.example.com.example.com: you typed the full domain in the name field. Enter just
www. - Site shows a security warning: the platform may still be issuing an SSL certificate. This usually resolves on its own once DNS checks pass.
- A trailing dot: some dashboards show targets ending in
.. That’s normal DNS notation for a full name and is fine.
Clean up old CNAMEs
If you stop using a service, delete its CNAME. A forgotten CNAME pointing at a cancelled account can sometimes let someone else claim that address and serve content on your subdomain. For the full process of pointing a domain at your site, see how to connect a domain to a website.
Frequently asked questions
Can I use a CNAME on my root domain?
Not under the DNS standards, because the root domain must also hold NS and SOA records and a CNAME can't share a name with other records. Many DNS providers offer a workaround called CNAME flattening, ALIAS or ANAME.
Is a CNAME a redirect?
No. A CNAME only changes where DNS looks for an address. The browser still shows your domain. A redirect, which changes the address in the browser, is set up on a web server or with a redirect service.
Can a CNAME point to an IP address?
No. A CNAME must point to another hostname. To point a name at an IP address, use an A record (IPv4) or AAAA record (IPv6).
Is it bad to chain CNAMEs?
It works, but every extra hop adds a lookup and another thing that can break. Point a CNAME straight at the final hostname where you can.
Sources