CNAME Record vs A Record: Which One to Use
Choose a CNAME or an A record with worked examples for www, a shop subdomain and the root domain, and avoid mistakes that can stop email.
Published 1 December 2026
Use an A record when your provider gives you a number, such as 192.0.2.10. Use a CNAME when it gives you a name, such as stores.example.net. A normal CNAME can work for www or shop, but not for the root domain, example.com. For the root, use your provider's A record or ask about a supported alternative.
Match the value to the record
192.0.2.10is an IPv4 address: use A.2001:db8::10is an IPv6 address: use AAAA. Add this only if your provider gives you one.stores.example.netis a host name: use CNAME for a subdomain that has no other records.https://example.net/my-shopis a web link: use neither. DNS stores the host name but not thehttps://or the page path.
These values are made up for this guide. Your real values must come from your hosting company or shop platform. If you need the basics of each type first, see DNS records explained.
What happens when a customer opens the shop
Suppose a customer types shop.example.com. In these two made-up examples:
- With an A record, DNS answers
192.0.2.10. The browser connects to that server. - With a CNAME, DNS says the name is an alias of
stores.example.net. A second lookup finds that name's address, and the browser connects to it.
If the platform changes its server address, it can update the address behind stores.example.net. Your CNAME stays the same. If you used an A record, you would need to change your own record.
The browser still shows shop.example.com, because a CNAME does not redirect the page. Before you add the DNS record, add that name in the platform's dashboard. If you do not, the platform may not know which shop to show, or may not have the right certificate.
Three record sets with made-up values
In these examples, @ means the root domain. Some DNS panels use a blank field instead. The numbers and names are placeholders, so replace example.com and every value with those from your own providers.
Normal hosting, with www on the same site
Name Type Value
@ A 192.0.2.10
www CNAME example.com
If the server's number changes, update the A record. www follows it. The hosting account and SSL certificate must include both names.
Main site on hosting, shop on another platform
Name Type Value
@ A 192.0.2.10
www CNAME example.com
shop CNAME stores.example.net
Only shop uses the second platform. Your main website and its records stay where they are.
Main site and www on one platform
Name Type Value
@ A 198.51.100.20
www CNAME sites.example.net
Use an A address for the root only if the platform tells you to. Do not look up the CNAME's current number and copy it. That number may change without notice. Some platforms need more than one A record or an extra check, so use their full list.
Why the root domain is different
The root always has SOA and NS records, which describe its DNS zone and nameservers. It often has MX records for email and TXT records for checks such as SPF. Under the basic DNS rule, a name with a normal CNAME cannot have these other records. A normal CNAME at the root conflicts with them and can affect the whole domain, including email.
Ask your providers which of these choices they support:
- A record: use the root address published by your website platform.
- CNAME flattening, ALIAS or ANAME: some DNS companies have a feature that looks up the target and answers with its address. For example, Cloudflare's CNAME flattening returns the final IP address instead of the CNAME.
- Root forwarding: use
wwwas the main website and forward the root to it. Make sure the forwarding service supports HTTPS, not just HTTP.
Do not change nameservers just to get this feature until you have copied every record, including email. Use this nameserver guide to find where your DNS is managed.
The same conflict on a subdomain
The rule also covers names such as shop.example.com. If shop has an A, AAAA, MX or TXT record, do not add a normal CNAME beside it. Screenshot the old record and find out what uses it before you replace it.
Your email server name has another rule: the name in an MX record should not be a CNAME. Here is a valid setup with made-up values:
Name Type Priority Value
@ MX 10 mail.example.com
mail A - 192.0.2.10
Replace the server name, address and priority with your email provider's values. Never change working MX records just to make them match this example. The dash means that the A record has no priority, so do not type it in the panel.
Make the change without losing email
- Screenshot or export all current records. Keep this copy as your backup.
- Find the provider that runs your nameservers. Changes in another company's panel will not work.
- Ask for the exact name, type and value. Enter only the part your panel needs. If it adds your domain automatically, typing
shop.example.commay createshop.example.com.example.com. Entershopinstead. - Change one website record. Do not delete MX or TXT records.
- Look up the name in the DNS checker. Type the full name, including
wwwif that is the one you changed. Then open the site overhttps. - Send an email to the domain and another from it. If something stops, compare the current records with your backup.
Common questions
Is a CNAME slower than an A record?
A CNAME can add another lookup, but DNS services often save the answers for a while. For most small sites, the right setup matters more. Use the type your provider asks for. Do not replace a supported CNAME with a copied IP address to save one lookup.
Can one name have two A records?
Yes. Different visitors may get different addresses. Add both only if your provider gave you both. One common mistake is leaving the old server's A record after moving. Some visitors may then reach the old site.
Can a CNAME open my Facebook page or WhatsApp chat?
Not with a page path. DNS cannot include an address such as /my-shop, and the social platform may not accept your domain. Use web forwarding to send your domain to a social page.
Do I need both A and AAAA records?
Not always. A is for IPv4 and AAAA is for IPv6. Add AAAA only if your provider gives you a working IPv6 address. If that address is old or wrong, the site may fail for visitors on IPv6.
Sources
- RFC 1034: aliases and canonical names
- RFC 1912: common CNAME mistakes
- RFC 2181: CNAME and MX rules
- Cloudflare: CNAME flattening