A CNAME (Canonical Name) record is a DNS record that makes one hostname an alias of another domain name, so it resolves through that target domain rather than directly to an IP address.
What is a CNAME record used for?
A CNAME record points a hostname, such as www or shop, to another domain name instead of an IP address. When someone visits that hostname, DNS looks up the CNAME target and then looks up the IP address for that target. This adds one extra lookup step, but it means the destination can change its IP address without you having to update your own DNS record.
Common reasons to use a CNAME record include:
- Pointing
www.example.comtoexample.comso both work the same way - Pointing a subdomain to a third-party service, such as a content delivery network or a platform like an online store builder
- Adding a subdomain for a hosted service (for example
mail.example.com) without needing to track that service's IP address yourself - Completing domain or service ownership verification when a provider asks you to add a specific CNAME record
A CNAME record only works at the DNS level. It does not redirect visitors or change the address shown in the browser; it simply tells DNS where to continue looking for the correct IP address.
Rules and restrictions for CNAME records
- A CNAME record cannot be used on the root domain (for example
example.comitself). The root domain must use an A or AAAA record instead. CNAME records are only valid on subdomains, such aswwworshop. - A CNAME record must point to a domain name, not an IP address.
- A hostname with a CNAME record cannot have any other record type, such as MX or A, on the same name. This matters most for the
@(root) hostname: if you set a CNAME there, email and other services for the domain will stop routing correctly. - Avoid pointing a CNAME record to another CNAME record. Chaining CNAMEs is technically possible but can cause slow lookups, loops or errors, so it is best avoided.
- Other record types that point to names, such as NS, MX, PTR and SRV, should never point to a CNAME record.
How to add a CNAME record
The steps depend on which control panel your hosting plan uses. You can check this in your welcome email or in the client area.
cPanel
- Log in to cPanel and go to the Domains section
- Click Zone Editor
- Find the domain you want to edit and click Manage, then choose the option to add a record
- Select Add CNAME Record
- In the Name field, enter the subdomain you want to use, such as
shop(cPanel will complete it asshop.example.com) - In the CNAME field, enter the target domain name you want it to point to
- Click Add a CNAME Record to save your changes
DirectAdmin
- Log in to DirectAdmin and go to Account Manager, then DNS Management
- Select the domain you want to edit
- Click Add Record
- Select CNAME as the record type
- Enter the subdomain name, the TTL (time to live, how long the record is cached, commonly 14400 seconds), and the target domain as the value
- If you type the target as a fully-qualified domain name, make sure it ends with a dot, for example
example.com. - Click Add to save the record
DirectAdmin does not let you edit an existing DNS record directly. To change one, add the new record first, then delete the old one.
Troubleshooting
- The record was rejected on the root domain: CNAME records are not allowed on the root domain (
@). Use an A or AAAA record there instead, and only apply the CNAME to a subdomain. - Email or other services stopped working after adding a CNAME: check that the hostname does not also have an MX, A or other record type. Remove the conflicting record or the CNAME, since a hostname can only use one or the other.
- The CNAME does not seem to work at all: confirm the domain is actually using your hosting account's nameservers. If the domain's DNS is managed elsewhere, such as through Cloudflare or another DNS provider, you need to add the CNAME record there instead, since changes in cPanel or DirectAdmin will not apply.
- Changes have not taken effect yet: DNS changes can take a few hours to spread across the internet, and in some cases up to 24–48 hours, depending on the record's TTL and on caching by other DNS resolvers.
If you have checked these points and the record still is not resolving correctly, contact Hostking support through live chat or by opening a support ticket from the client area.