Guide
A record vs CNAME record: what is the difference?
An A record points a name directly to an IP address, while a CNAME record points a name to another name. Use an A record to send your main domain to your hosting server, and a CNAME to make a name such as www follow another name. The most common mistake is putting a CNAME on the bare domain, which is not allowed alongside other records.
The basics
Two ways to say where a name goes
The Domain Name System is the internet’s address book. When someone types your domain into a browser, the browser asks DNS where to find it, and DNS answers using records. Two of the most common records are A and CNAME, and they do the same job in different ways.
An A record, short for address record, links a name to an IPv4 address, which is a string of numbers such as 203.0.113.10. When a visitor looks up yourbusiness.co.uk, the A record gives the address of the server that holds your site. A matching AAAA record does the same for the newer IPv6 addresses.
A CNAME record, short for canonical name, links one name to another name instead of to an address. If www.yourbusiness.co.uk has a CNAME pointing to yourbusiness.co.uk, anyone asking for www is sent to wherever the main name goes. Our guide to what DNS is gives the wider picture.
Comparison
A record and CNAME side by side
| Point | A record | CNAME record |
|---|---|---|
| Points to | An IP address | Another domain name |
| Typical use | The main domain and servers you control | www, and services run by another company |
| If the server address changes | You must update the record | You do nothing; it follows the other name |
| On the bare domain | Allowed | Not allowed with other records on the same name |
| Can sit beside other records | Yes | No, a CNAME must be the only record for its name |
| Extra lookup needed | No | Yes, one more step to find the address |
A bare domain, also called the apex or root, is the name with nothing in front, such as yourbusiness.co.uk.
Setting up
A typical setup for a website
Find your server address
Your host gives you the IP address of your hosting server in your welcome email or client area.
Add an A record for the bare domain
Create an A record with the name @ (meaning the bare domain) pointing to that IP address.
Add a CNAME for www
Create a CNAME record with the name www pointing to your bare domain, so both versions reach the same site.
Check mail records stay in place
Do not delete your MX records. They send email and are separate from the website records.
Wait and test
Allow time for the change to spread, then visit both addresses. See how to point a domain to hosting.
Worked example
A worked example: a shop with a booking tool
Imagine a salon owner, Priya, who runs salonpriya.co.uk on her hosting account and uses an online booking service at a separate address, bookings.example.com. She wants customers to visit book.salonpriya.co.uk and see the booking page.
For the main site, she adds an A record: name @, value the hosting server’s IP address. For www, she adds a CNAME pointing to salonpriya.co.uk. For the booking page, she adds a CNAME with the name book, pointing to the name the booking company gave her.
Now customers visiting the main site reach her hosting account. Customers visiting book.salonpriya.co.uk are sent to the booking company, who can change their servers without her ever touching the record again. That is the benefit of a CNAME for a service run by someone else.
Common mistakes
Mistakes that break a site
The most common mistake is adding a CNAME to the bare domain. The rules of DNS say a CNAME cannot share a name with other records, and the bare domain always needs records for mail and other things, so most DNS providers refuse it or break email if allowed.
Another is leaving an old A record in place when you add a new one. A name with two A records may send some visitors to the old server and some to the new one, which looks like a site that works and does not.
A third is a CNAME that points to another CNAME that points back to the first, a loop that never resolves. Keep chains short, and check the final name has an A record.
Finally, remember that changes take time. If you have just edited records and the site does not load, see fixing a website not loading after a DNS change before you change anything else.
Before you save
A DNS record checklist
- The bare domain has an A record pointing to your server
- www has a CNAME pointing to the bare domain, or its own A record
- There are no duplicate A records for the same name
- MX records for email are still in place
- Any CNAME is the only record for its name
- You copied values exactly, with no stray spaces
- You noted the old records before changing them
- You tested both the bare and www addresses
Other records
How A and CNAME fit with the other records
A and CNAME records are only two of the entries a typical domain has. MX records route email. TXT records hold text used for checks, such as SPF for mail and domain verification for other services. NS records name the nameservers. Each has its own job, and they sit side by side in the same zone.
When you move a website, you usually change only the A record and perhaps the www record. Leaving the others alone keeps your email and other services working. When you move email, you change the MX records and the related TXT records, and leave the website records alone.
If you are unsure what a record is for, do not delete it. Look it up, or ask the company that gave you the instructions. A forgotten TXT record can be what proves your domain to a service you use, and removing it can quietly break something weeks later.
Checking
How to check what your records say today
You do not need special tools to see your records. Many registrars and hosts show them in a DNS editor. Free online lookup tools show what the wider internet sees, which can differ from what you edited if a change is still spreading.
Look up the A record for your bare domain and for www, and confirm both give the address you expect. If www shows a CNAME, follow it to the name it points to and check that name has an A record. A short chain with a clear end is a healthy setup.
Keep a note of your records somewhere safe, with dates. When something breaks, a copy of how it used to look is the quickest way to find what changed.
Hosting and a .co.uk domain in one place
UK servers in London, free SSL and live chat open 24/7 on every plan, from 84p a month (£10.03 billed yearly).
FAQ
Common questions
What is the difference between an A record and a CNAME?
An A record points a name to an IP address. A CNAME points a name to another name, which then leads to an address.
Can I use a CNAME for my main domain?
Not safely. A CNAME cannot sit beside the other records the bare domain needs, such as MX records. Use an A record there.
Which should I use for www?
A CNAME pointing to your bare domain is common and simple, though an A record also works.
Do A records affect email?
No. Email is routed by MX records. Keep them when you change website records.
What is an AAAA record?
The IPv6 version of an A record. It points a name to an IPv6 address.
Keep reading
Related pages
Get your site and domain working together
Free SSL and live chat on every plan, with a 15-day money-back guarantee.