Can you use a CNAME on a root domain? Apex records, ALIAS and flattening

A CNAME can't share a name with other records, so it breaks at the root domain. Why, what to use instead (A, ALIAS, ANAME, CNAME flattening), and how to point example.com at a host.

· 6 min read · By the Spot Downtime team

Your host tells you to add a CNAME pointing to something.hosting-provider.com. That works for www.example.com. At example.com itself, the root of the domain (also called the apex or naked domain), your DNS provider refuses, or worse, accepts it and email stops arriving.

This is one of the most common DNS surprises. It is a rule of the DNS protocol, not a bug in your provider.

Why a CNAME can't live at the apex

A CNAME record says “this name is an alias for that other name”. The rule (RFC 1034) is that if a name has a CNAME, it cannot have any other record type. The resolver is meant to follow the alias for everything.

The root of a zone always has other records: the SOA and NS records that define the zone itself, and usually MX for email and TXT for SPF and domain verification. A CNAME there would conflict with all of them. So a standards-following DNS provider will not let you create it.

Same rule for any name with other records

This is not only about the apex. You also cannot add a CNAME on mail.example.com if that name already has an A or TXT record. The apex is just the place it comes up most, because it always has records.

What happens if a provider allows it anyway

Some providers let you create the conflict. Behavior is then undefined and resolvers disagree. Typical results are that MX lookups follow the alias and fail, so incoming mail bounces, or that SPF and verification TXT records vanish from the answers. If you have a CNAME at the root and mail has gone missing, remove it first. See SPF, DKIM and DMARC for what depends on those records.

Your options

1. Use an A (and AAAA) record

If the host gives you fixed IP addresses, use them. This is the simplest and most portable option:

example.com.      300  IN  A      203.0.113.10
example.com.      300  IN  AAAA   2001:db8::10
www.example.com.  300  IN  CNAME  example.com.

The downside is that if the provider changes its IPs, your site breaks until you update the record. Only do this when the provider publishes stable addresses and promises to keep them.

2. Use an ALIAS, ANAME or flattened CNAME

Many DNS providers offer a record that looks like a CNAME in the dashboard but behaves differently. They go by different names: ALIAS, ANAME, or “CNAME flattening”. The provider's nameservers resolve the target name themselves and answer the query with the resulting A and AAAA records. To the outside world the apex has plain address records, so it coexists with MX and TXT.

These are provider-specific features, not DNS standards. Cloudflare flattens CNAMEs at the apex automatically. Other providers offer an ALIAS or ANAME record type, and some offer nothing, so check your provider's documentation. If you move DNS providers, you will need to recreate the setup.

One caveat: the answer comes from the provider's own lookup, so geographic routing done by a CDN may be based on the provider's resolver location rather than the visitor's. For most sites this is fine.

3. Redirect the apex to www

Make www.example.com the canonical site, where a CNAME is allowed, and have the bare domain redirect to it. The apex needs an A record pointing at something that serves the redirect (often a redirect feature at your registrar or DNS provider), and the redirect itself must work over HTTPS too, which means a certificate for the bare name.

example.com.      300  IN  A      203.0.113.20   ; redirect service
www.example.com.  300  IN  CNAME  your-site.hosting-provider.com.

4. Use the provider's nameservers

Some hosting platforms offer to host your DNS, so they manage the apex records for you. This works well, but remember that every other record (MX, TXT, subdomains) must be copied across before you change nameservers, or you will break email.

How to check what you have

Query the apex and see which record types come back:

dig example.com A +short
dig example.com MX +short
dig example.com TXT +short
dig www.example.com CNAME +short

If MX or TXT comes back empty at the apex but you know you set them, a conflicting CNAME is a prime suspect. Run the same queries against your provider's authoritative nameserver (dig @ns1.example-dns.com example.com MX) to bypass caches. After a change, keep TTL and propagation in mind.

Checklist

  1. List all records at the apex before changing anything. Save a copy.
  2. Remove any CNAME at the apex that your provider allowed.
  3. Choose A/AAAA, ALIAS/ANAME/flattening or a www redirect.
  4. Confirm MX and TXT records still resolve with dig.
  5. Make sure both example.com and www.example.com have a valid HTTPS certificate.
  6. Lower the TTL ahead of the change so a rollback is quick.

Watching it after the change

DNS changes fail quietly: the site may work from your laptop while another region still sees the old answer, or email breaks days later. Check the apex and www as separate URLs after a change, and keep monitoring both. See DNS_PROBE_FINISHED_NXDOMAIN for what visitors see when a name stops resolving.

DNS lookupLook up A, AAAA, CNAME, MX and TXT records for your domain.DNS propagation checkerSee whether a DNS change has reached resolvers in different locations.

Get new guides by email

Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.

Unsubscribe from any email with one click. See our privacy policy.

Keep reading