Blog · WebJi® India

CNAME Record Explained

Quick answer: A CNAME record (DNS type 5) aliases one hostname to another and never stores an IP. The resolver follows the alias, then reads the target A or AAAA record. Change that address once and every alias follows. The name cannot also hold MX, TXT, or A, and a CNAME cannot sit on the bare domain.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Indian trader monitoring candlestick charts on multiple screens in evening light — cname record explained

CNAME Explained (An Alias for a Hostname)

A CNAME, short for canonical name, is DNS record type 5. The value is another hostname, the canonical name, not an address. www.example.com can point at example.com. The resolver returns the CNAME, looks up example.com, and uses that name's A or AAAA record. The browser still requests www.example.com.

  • The value is a hostname, never an IPv4 or IPv6 address.
  • The target may be in the same domain or a different one.
  • The name that holds the CNAME cannot also hold A, MX, TXT, or a second CNAME.
  • One address change on the target updates every alias that points at it.

The alias can target the same domain or a different one, such as a shop or CDN hostname. Change the address on the target and every CNAME that points there follows. The wider set of record types is in DNS records explained.

CNAME vs A Record

An A record stores an IPv4 address. A CNAME stores a hostname and sends the resolver to look that name up. Use an A record for the bare domain and for mail hosts. Use a CNAME when a label should keep following another hostname, such as www.

FactorCNAMEA record
Points toAnother hostnameAn IPv4 address
DNS type51
CoexistenceMust be the only record at that nameCan sit with MX, TXT, and NS
At the apexNot valid, because SOA and NS already existNormal for the bare domain
After an IP changeFollows the targetEdit each A record
Typical usewww, a CDN hostname, a verification nameApex and mail hosts

Mail and the apex need records that can share a name. A CNAME cannot. The side-by-side choice, including when mail is involved, is in A record vs CNAME.

Indian trader monitoring candlestick charts on multiple screens in evening light — cname record explained

The Root-Domain Rule: Why the Apex Needs A or Flattening

The apex is the bare domain, example.com, with no label in front. That name already has SOA and NS records. A CNAME has to be the only record at its name, so a normal CNAME on the apex is invalid. Put an A record, and an AAAA record if you publish IPv6, on the apex. Put the CNAME on www or another label.

Some DNS hosts offer a panel row that looks like a CNAME at the root and answers with an address. A cPanel zone stores a real CNAME, so it will not accept that on the apex. The workaround is the flattening section below.

Common Uses: www, CDN and SaaS Verification

Three uses cover almost every CNAME on a hosting account. Point www at the apex so both names share one address. Point a hostname at a CDN or platform name they gave you, so they can change servers without you editing an A record. Add the verification CNAME a vendor sends, on a label that has no other record.

A CNAME to another company's domain only publishes the alias. Their server still has to accept your hostname. It is also not an HTTP redirect: the address bar keeps the name people typed.

Creating a CNAME in the cPanel Zone Editor

Linux shared and WordPress plans use cPanel for the zone. Edit that zone only when the domain's nameservers already point at the account. A matching record saved at the registrar does nothing while those nameservers point at the host.

  1. Confirm the live nameservers are the account whose Zone Editor you are opening.
  2. In cPanel, open Zone Editor and choose Manage beside the domain.
  3. Add a CNAME record. In Name, type only the label, such as www or shop.
  4. In the target field, type a hostname, not an IP. Save the row.
  5. Look up the full name. The CNAME answer should be that hostname. The address appears only on the next lookup.

You know it worked when Zone Editor shows type CNAME and a lookup of the full name returns the target, not an IP, in the CNAME answer. If the saved name is www.example.com.example.com, Name included the domain and the panel appended it again. Change Name to the label only, such as www.

CNAME Not Working: Propagation and Conflicts

A CNAME fails for a short list of reasons. Another record on the same name blocks it. A target with no A or AAAA record, or a chain of CNAMEs that never reaches one, returns no address. A chain is allowed and adds lookups. Point at the final hostname when you can.

Confirm the registrar lists the nameservers for the zone you edited. If a lookup still shows the old answer, caches have not expired yet. How long that takes is DNS propagation, and a fresh lookup is how you check DNS records.

CNAME Flattening (Workaround Explained)

CNAME flattening, ALIAS, and ANAME are names for the same idea. You type a hostname at the apex, and the DNS host looks it up and answers with an address. On the wire that answer is not a CNAME, which is why SOA, NS, and MX can remain.

A WebJi® cPanel zone has no flattening switch. Keep an A record on the apex and use a CNAME only on a label such as www. If a vendor requires the apex itself to be a CNAME, the zone has to live at a DNS host that offers flattening or ALIAS. Do not delete the apex NS or SOA records to force one.

Frequently Asked Questions

What is a CNAME record?

A CNAME (canonical name) record is DNS type 5. It points one hostname at another hostname. Resolvers then look up that target for the A or AAAA address.

Can a CNAME record be an IP address?

No. The value must be a hostname. An IPv4 address belongs in an A record, and an IPv6 address belongs in an AAAA record. If a panel stores an IP in a CNAME field, that record is invalid.

Can you have a CNAME without an A record?

The CNAME name itself has no A record, and it must not have one. Visitors still need some name in the chain to have an A or AAAA record. Until that target has an address, the alias does not resolve.

Can a CNAME point to a different domain?

Yes. www.example.com can point at example.com, or shop.example.com can point at a hostname the shop platform gave you. Their server has to answer for your hostname. The CNAME only publishes the alias.

Is a CNAME just a redirect?

No. A CNAME changes which address a name resolves to. The browser still requests the original hostname. A redirect is an HTTP response, such as a 301, and it can change the address people see. The two settings are separate.

Can I add a CNAME at the root domain?

Not as a standard CNAME. The bare domain already has SOA and NS records, and a CNAME cannot share that name. Use an A record on the apex. Use a CNAME on www or another label. Flattening or ALIAS belongs to some DNS hosts, not to a normal cPanel zone.

Why is my CNAME not working?

Check four things: the name has no other record, the target hostname has an A or AAAA record, you edited the zone the live nameservers publish, and old caches have expired. A doubled name such as www.example.com.example.com means the label was entered as a full domain.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →