Skip to main content

What is a CNAME record? Explanation and examples

Published on June 19, 2026 7 min read

Learn what a CNAME record is and how to use one to point a subdomain as an alias to another hostname, with clear examples and key rules.

Flat vector illustration of a person at a signpost with an orange arrow pointing from one card to another and on to a server cabinet, illustrating a CNAME alias.

A CNAME record is a DNS setting that points one hostname to another hostname. Instead of an IP address, you give a CNAME record a target name, for example www.example.com pointing to example.com. This page explains what a CNAME record is, how it works, when to use one, how to set it up at LJPc, and which rules and limits to keep in mind.

What is a CNAME record?

CNAME stands for Canonical Name. It is one of the standard DNS record types (type 5) and is defined in RFC 1035 from 1987. A CNAME record turns a name into an alias: it maps that name to another hostname, known as the canonical name.

The difference from an A record or AAAA record matters. An A record links a name to an IP address. A CNAME record links a name to another name. The DNS server then looks up the matching IP address at that other name itself.

How does a CNAME record work?

Say a visitor requests www.example.com and a CNAME record there points to example.com. Here is what happens:

  1. The DNS server sees the CNAME record and knows that www.example.com is an alias of example.com.
  2. The server then looks up the A and AAAA records of example.com.
  3. Those records return the IPv4 and IPv6 address of the server.
  4. The visitor connects to that address.

The benefit is that you only manage the underlying address in one place. If the IP address of example.com changes, www.example.com follows automatically, because the alias points to the name and not to a fixed address.

When do you use a CNAME record?

A CNAME record is useful whenever you want one name to follow another name. The most common cases are:

  • www to your main domain: the classic example is www.example.com as an alias of example.com, so both addresses reach the same website.
  • External services and CDNs: many platforms for online stores, newsletters, or a content delivery network (CDN, a network that serves your site faster) ask you to point a subdomain to their servers with a CNAME.
  • Domain verification: some services have you create a unique CNAME record to prove that you own the domain.
  • Maintenance in one place: because the alias follows the name and not the address, you only need to update the target when you move to a new server.

How to create a CNAME record

The exact steps depend on where you manage your DNS, but the approach is similar everywhere. In your DNS manager or control panel, you create a new record with the following details:

  1. Type: choose CNAME.
  2. Name (host): the name you want to set as an alias, such as www or a subdomain like shop.
  3. Target (value): the full hostname you are pointing to, such as example.com or a name your external service gives you. In the customer portal this field is called Content.
  4. TTL: how long the record may be cached. 3600 seconds (one hour) is a common value and is already filled in in the customer portal.
  5. Save: save the record and wait for the change to take effect.

Setting up a CNAME record at LJPc

Where you create the record depends on what you have with LJPc:

  • Hosting package: you manage the DNS in Plesk. You open Plesk from the customer portal, see Open Plesk from the customer portal, and add the record there.
  • DNS management only at LJPc: you manage the DNS in the customer portal. In the Services menu, open the Domains page, click your domain and click Add record under DNS records. Choose CNAME as the Type, enter the alias under Name (for example shop), the target name under Content and click Save.

The step-by-step guide for both routes is in Manage DNS records. If you want a subdomain to have its own website as well, see Create a subdomain.

At LJPc, a www record is already in place by default as a CNAME that points to your main domain, with a hosting package and also when you add DNS management in the portal. That way www and your bare domain use the same address right away.

A new or changed CNAME does not appear everywhere at once. At LJPc a change usually reaches our name servers within a minute. Servers that still have the old value in their cache only see the new one once the TTL expires. Because of that, it can take up to 48 hours for the change to roll out worldwide, although it is usually much faster. Read more in DNS propagation.

Example of a CNAME record

Below are two common examples. In the first case, www.example.com is an alias of example.com. In the second case, shop.example.com points to the server of an external service.

Examples of a CNAME record
NameTypeTarget
wwwCNAMEexample.com
shopCNAMEcustomers.external-service.com

Important rules and limits

A CNAME record is powerful, but a few strict rules apply. Break them and your domain or email may stop working.

No CNAME on your main domain

You cannot set a CNAME record on the main domain itself, that is example.com with nothing in front of it. This is called the apex or root. The DNS standard requires that a CNAME record not coexist with any other record on the same name, and the apex always has mandatory NS and SOA records, so a CNAME there is never valid.

If you want your bare domain to point to another server, use an A record with that server's IPv4 address, and an AAAA record if the server also has an IPv6 address. Some DNS providers offer their own record type for this, such as ALIAS or ANAME, or call it CNAME flattening. That is not part of the DNS standard; at LJPc you use an A and an AAAA record on the main domain. If an external service only gives you a hostname, ask for the IP addresses for your main domain and put the CNAME on www. If you try to save a CNAME on the main domain in the customer portal anyway, you get a message that this is not allowed.

A CNAME always stands alone

On the name that holds a CNAME record, no other records are allowed. So you cannot put both a CNAME and a separate A record or TXT record on www at the same time. If you need another record type on that name in addition to the alias, use an A and AAAA record on that name instead of the CNAME. The customer portal checks this and shows a message if a CNAME would share a name with another record.

MX and NS never point to an alias

According to the DNS standard (RFC 2181), the target of an MX record or NS record may not be an alias. So in an MX record, point your mail server directly to a hostname that has an A or AAAA record, not to a CNAME.

Avoid long chains

A CNAME may point to a name that is itself a CNAME, but every extra step costs a lookup and makes resolution slower and more error-prone. Keep chains as short as possible and point straight to the final hostname where you can.

How to check a CNAME record

You can verify a CNAME record yourself. Use one of these commands from your own computer.

Look up a CNAME record by operating system
Operating systemCommand
macOS or Linuxdig CNAME www.example.com +short
Windowsnslookup -type=CNAME www.example.com

The answer shows the canonical name the alias points to. If you see no CNAME, the record has not propagated yet or sits on a different name.

Troubleshooting

If a CNAME record does not work as expected, check these common causes.

Common problems with a CNAME record
ProblemCauseSolution
The change is not visible yetThe old value is still cached (TTL)Wait until the TTL expires, up to 48 hours
Error when saving on the main domainA CNAME is not allowed on the apexUse an A and an AAAA record
The record will not save next to other recordsA CNAME may not sit alongside other records on the same nameRemove the other records or pick a different name
Message Invalid hostname in the customer portalThe content is not a full hostname, for example an IP address or a name without a dotEnter the full target name, such as example.com or customers.external-service.com
Email does not arriveAn MX record points to a CNAMEPoint the MX record to a name with an A or AAAA record

With a CNAME record, you keep your DNS tidy: you manage the underlying address in one place and let aliases move along automatically. Still stuck? Read Troubleshoot DNS problems or create a support ticket and we will be glad to help.

Frequently asked questions

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

An A record links a name to an IP address. A CNAME record links a name to another hostname. With a CNAME, the DNS server then looks up the IP address at that other name itself.

Can I put a CNAME record on my main domain?

No. The DNS standard requires that a CNAME record not coexist with any other record on the same name, and the apex always has mandatory NS and SOA records, so a CNAME there is never valid. At LJPc you use an A and an AAAA record on the main domain. Record types such as ALIAS or ANAME, which some other DNS providers offer, are not part of the DNS standard.

Is there already a CNAME record for www at LJPc?

Yes. With a hosting package, and when you add DNS management in the customer portal, www points to your main domain with a CNAME by default. That way www and your bare domain reach the same website right away.

Where do I create a CNAME record at LJPc?

If you have a hosting package, you add the record in Plesk, which you open from the customer portal. If you only have DNS management at LJPc, open your domain in the customer portal and click Add record under DNS records.

How long does it take for a CNAME record to work?

At LJPc a change usually reaches our name servers within a minute. Servers that still have the old value in their cache only see the change once the TTL expires. In the worst case it can take up to 48 hours for the change to apply everywhere.

Can a CNAME record point to another CNAME record?

It can, but it is not recommended. Every extra link costs a lookup and makes name resolution slower and more error-prone. Point straight to the final hostname where you can.

How do I check a CNAME record?

On macOS or Linux, use the command dig CNAME name +short. On Windows, use nslookup -type=CNAME name. The answer shows the hostname the alias points to.

Can I point an MX record to a CNAME?

No, the DNS standard does not allow it. An MX record must point to a hostname that has its own A or AAAA record, not to an alias.

Prefer to talk to someone?

We are also happy to answer your questions personally. Schedule a free consultation or call us directly. We are glad to think along with you.

Stay up to date with recent developments! Subscribe and receive our newsletter Signing up...