The records you will meet in nearly every zone
Difference Between CNAME and A Record: When to Use Each
Both records point a hostname somewhere. The difference between a CNAME and an A record is what they point at, and it determines who is responsible for keeping the configuration correct when an IP address changes.
| A record | CNAME record | |
|---|---|---|
| Points to | An IP address | Another hostname |
| Example | 93.184.216.34 | myapp.herokudns.com |
| Extra lookup? | No — final answer | Yes — resolve the target too |
| Allowed at root? | Yes | No (see below) |
| Other records alongside? | Yes | No — must be alone |
| Updates when IP changes? | You must edit it | Automatic |
The decision, in one question
Key takeaway
Do you control the IP address and know it will not change? Use an A record. Are you pointing at a service someone else operates? Use a CNAME, so their address changes do not break you.
That is genuinely the whole decision for most people. The rest of this article is the details that bite.
How a CNAME resolves
CNAME stands for Canonical Name. It says: this name is an alias — go look up that other name instead.
shop.example.com. 3600 IN CNAME stores.myshopify.com.
stores.myshopify.com. 300 IN A 23.227.38.65A resolver asking for shop.example.com gets the CNAME, then resolves stores.myshopify.com, then returns 23.227.38.65. Two lookups instead of one — a few milliseconds, almost always cached.
The benefit is that when Shopify moves to a new address, they change one A record on their side and your domain follows automatically. With an A record, you would be down until you noticed and edited it yourself.
The root-domain restriction
This is the single most common DNS frustration, and it is a protocol rule, not a limitation of your provider.
This is why hosts that only give you a hostname (myapp.herokuapp.com) create a problem at the root. There are three ways out:
ALIAS / ANAME / CNAME flattening
Many DNS providers offer a synthetic record type that behaves like a CNAME at the root. The provider resolves the target itself and serves the resulting IP as a normal
Arecord, so the protocol rule is never broken. Cloudflare calls this CNAME flattening; Route 53 calls it an alias record.Redirect the root to www
Point the root at a small redirect service and put the CNAME on
www. Simple and universally supported, at the cost of one extra hop for visitors.Use an A record and accept the maintenance
If your provider publishes stable IPs and documents them as static, an A record at the root is fine. Confirm they guarantee stability — many explicitly do not.
A CNAME must be alone
If a name has a CNAME, it may have nothing else — no A, no MX, no TXT.
mail.example.com. IN CNAME ghs.googlehosted.com.
mail.example.com. IN TXT "v=spf1 include:_spf.google.com ~all"Some providers reject this outright; worse, some accept it and behave unpredictably. If you need a TXT record on a name, that name cannot be a CNAME.
When each is the right call
Use an A record for
- Your root domain, in nearly every case.
- A server you run on a static IP — a VPS, a dedicated box, a reserved cloud address.
- Anywhere you need other records on the same name.
MXtargets, which must resolve to addresses.
Use a CNAME for
- Subdomains pointing at a managed platform (Shopify, Heroku, Netlify, Vercel).
www, pointed at your root or your host's hostname.- Domain-verification subdomains that providers ask you to create.
- Anything whose underlying IP is not yours to control.
Checking what you have
dig +short www.example.com CNAME
dig +short www.example.com AThe lookup tool shows A, AAAA, and CNAME records together for any domain, which makes it easy to spot a name that has both when it should not.
Need to check a domain's public DNS addresses? Use the Domain IP Lookup tool.
Free tools for this topic
Frequently asked questions
Related reading
The records you will meet in nearly every zone
DNS A Records Explained: How Domains Map to IPv4
The record that actually points your domain at a server — its anatomy, the AAAA counterpart, and the four mistakes that break sites most often.
The records you will meet in nearly every zone
DNS Record Types Explained: A, AAAA, CNAME, MX and TXT
Every record type worth knowing, what it does, what it looks like, and the mistake people make with it — in one reference page.
A recursive DNS lookup, one hop at a time
Browser
wants example.com
Resolver
your ISP / 1.1.1.1
Root + TLD
who runs .com?
Authoritative
the real answer
Every hop down this chain is itself a DNS lookup, cached afterward
What Is a DNS Nameserver? How It Works
The single setting that decides which provider controls your DNS — and the reason your record edits sometimes have no effect at all.