What is a CNAME record?

Home / Everything About / Everything About Domains / What is a CNAME record?

If you have read the chapter on DNS record types, you already know that each record stored on a name server has a specific job. An A record maps a domain name to an IP address. An MX record handles email routing. A CNAME record works differently from both. Instead of pointing to an IP address or a mail server, it points one domain name to another domain name. That simple difference makes it one of the most useful and most misunderstood records in DNS.

What does CNAME stand for?

CNAME stands for canonical name. In this context, "canonical" means the official or primary version. When you create a CNAME record, you are saying that one hostname is just an alias for another. The target hostname is the canonical name, and the alias follows it wherever it goes.

For example, if you set up a CNAME record so that "www.yoursite.com" points to "yoursite.com," you are telling DNS that "www.yoursite.com" is an alias. The canonical name is "yoursite.com." Any time someone looks up the www version, DNS follows the alias and resolves the canonical name instead.

How does a CNAME record work?

A CNAME record explained in simple terms works like a forwarding address. The browser asks DNS for the IP address of a hostname. DNS finds a CNAME record on that hostname. Instead of returning an IP address, it returns another domain name. The browser then looks up that second domain name and follows its A record to reach the actual server.

Here is what happens step by step.

  • A visitor types "blog.yoursite.com" into a browser
  • The browser asks DNS to resolve "blog.yoursite.com"
  • DNS finds a CNAME record pointing "blog.yoursite.com" to "yoursite.com"
  • DNS then looks up the A record for "yoursite.com"
  • The A record returns the IP address of the server
  • The browser connects to that IP address and loads the page

The extra step happens behind the scenes and takes only milliseconds. The visitor never sees it. The benefit is that if you change the IP address on the A record for "yoursite.com," every CNAME alias pointing to it automatically follows. You update one record instead of many.

What does a CNAME record look like?

A CNAME record has four parts. Each one serves a specific purpose.

  • Hostname (name) is the alias you are creating. This is the domain name that will point somewhere else. Example value is "www" or "blog"
  • Type tells DNS this is a CNAME record
  • Target (value) is the canonical domain name the alias points to. Example value is "yoursite.com"
  • TTL (time to live) controls how long DNS servers cache this record before checking for updates. It is measured in seconds. A common value is 3600, which means one hour

In a DNS management panel, a typical CNAME record entry would show "www" as the hostname, "CNAME" as the type, "yoursite.com" as the target, and "3600" as the TTL.

When should you use a CNAME record?

CNAME records are useful any time you want one hostname to follow another. The most common situations include the following.

Pointing www to your root domain

The most common use of a CNAME record is making "www.yoursite.com" point to "yoursite.com." The root domain has an A record with the server's IP address. The www version has a CNAME pointing to the root. If the server IP changes, you only update the A record. The www alias follows automatically.

Connecting subdomains to external services

Many third-party services ask you to create a CNAME record to connect your subdomain to their platform. For example, you might point "shop.yoursite.com" to an external service's server address. The CNAME lets you use your own domain name while the service handles the hosting behind the scenes.

Setting up a CDN

A content delivery network (CDN) speeds up your website by serving files from servers closer to each visitor. To use a CDN, you often create a CNAME record pointing your domain or subdomain to the CDN provider's address. This routes your traffic through their network without changing your actual hosting setup.

Managing multiple subdomains efficiently

If you have several subdomains that all need to reach the same server, you can point them all as CNAME aliases to one domain that has the A record. When the server IP address changes, you update one A record instead of updating every subdomain individually.

What is the difference between a CNAME record and an A record?

The main difference is what each record points to. An A record maps a domain name directly to an IP address. A CNAME record maps a domain name to another domain name. The A record is the final destination. The CNAME is a redirect that leads to the final destination.

Here are the key differences.

  • An A record holds an IP address. A CNAME holds a domain name
  • An A record can exist on any hostname, including the root domain. A CNAME cannot exist on the root domain
  • An A record resolves in one step. A CNAME adds an extra lookup step because DNS has to follow the alias and then resolve the target's A record
  • An A record needs to be updated manually if the IP address changes. A CNAME automatically follows whatever IP address the target resolves to

Use an A record when you know the IP address and it is unlikely to change. Use a CNAME when you want a hostname to follow another hostname, especially when the IP address behind it is managed by someone else.

What are the rules and limitations of CNAME records?

CNAME records have specific rules in the DNS specification that make them different from other record types. Breaking these rules causes errors that can take your website or email offline.

A CNAME cannot exist on the root domain

The DNS specification does not allow a CNAME record on the root (apex) domain. The root domain is the bare version of your domain without any prefix, like "yoursite.com" instead of "www.yoursite.com." This restriction exists because CNAME records cannot coexist with other record types on the same hostname, and the root domain needs other records (like MX records for email and NS records for nameservers) to function.

If you need the root domain to point somewhere, use an A record instead. Some DNS providers offer a workaround called ALIAS or ANAME records, which work like a CNAME but are allowed on the root domain. Not every provider supports this.

A CNAME cannot share a hostname with other records

If a hostname has a CNAME record, it cannot have any other record types on that same hostname. No A records, no MX records, no TXT records. The CNAME must be the only record on that name. This is why you cannot place a CNAME on the root domain, because the root domain already needs NS records and usually needs MX and TXT records too.

CNAME chains should be avoided

A CNAME chain happens when one CNAME points to another CNAME, which points to another CNAME, before finally reaching an A record. While DNS can technically follow these chains, each hop adds lookup time and increases the chance of a timeout or failure. Keep it simple. Point each CNAME directly to a hostname that has an A record.

How do you add a CNAME record?

Adding a CNAME record follows the same general steps with most DNS providers. The exact layout of the settings page varies, but the information you enter is the same everywhere.

  1. Log in to the DNS management panel where your domain's nameservers are set. This is usually your domain registrar or your hosting provider
  2. Find the DNS records section or DNS zone editor
  3. Click the option to add a new record
  4. Select CNAME as the record type
  5. Enter the hostname you want to create as the alias (for example, "www" or "blog")
  6. Enter the target domain name the alias should point to (for example, "yoursite.com" or a service provider's address)
  7. Set the TTL. If you are unsure, use the default value your provider suggests or set it to 3600 (one hour)
  8. Save the record

DNS changes can take anywhere from a few minutes to 48 hours to spread across the internet. This delay is called DNS propagation. During this time, some visitors may still see the old settings while others see the new ones. For more on how this process works, read the chapter on how DNS works.

What are common CNAME mistakes?

Most CNAME problems come from a few repeated errors. Knowing them upfront saves time and prevents downtime.

  • Placing a CNAME on the root domain. This breaks DNS. Use an A record on the root domain instead
  • Adding other records alongside a CNAME. If a hostname has a CNAME, it must be the only record on that hostname. Adding an MX or TXT record to the same hostname causes conflicts
  • Creating CNAME chains. Pointing one CNAME to another CNAME to another CNAME adds unnecessary lookups. Point each CNAME directly to a hostname that resolves with an A record
  • Forgetting the trailing dot. Some DNS providers require a trailing dot at the end of the target domain (like "yoursite.com.") to indicate it is a fully qualified domain name. Leaving it off may cause the provider to append extra text to the target
  • Using a CNAME when an A record is better. If you control the server and the IP address is stable, an A record is simpler and resolves faster. Use a CNAME when the target IP address may change or is managed by a third party

How WEMASY handles CNAME records

When you connect a custom domain to your WEMASY website, WEMASY tells you exactly which DNS records to add. For subdomains, this usually means creating a CNAME record pointing to WEMASY's servers. WEMASY handles the hosting, SSL, and routing on the other end, so once the CNAME is in place, your subdomain connects to your site automatically.

For root domains, WEMASY provides the A record values instead, since CNAME records cannot be used on the root. The setup guide walks you through both options depending on which type of domain you are connecting. See what is included in each plan on the WEMASY pricing page.

What comes next

Now that you understand how CNAME records create aliases between domain names, the next chapter covers another essential record type. MX records control where your domain's email gets delivered, and they follow their own set of rules. That is covered in the next chapter on what an MX record is. For an overview of all record types and when to use each one, see the chapter on DNS record types.

Can a CNAME record point to an IP address?

Does a CNAME record affect website speed?

What happens if the target of a CNAME record goes offline?

Is a CNAME the same as a redirect?

Can you use a CNAME and an A record on the same hostname?