Black Friday: 60% off yearly plans with code BF2026, until November 30. See the deal

Learn

CNAME record: what it is and how it works

A CNAME (canonical name) record makes one hostname an alias of another: a resolver that finds a CNAME restarts the lookup at the target name and returns that answer. It is used for subdomains such as www or shop that should follow another hostname, and it cannot share a name with other records.

The short answer
  • A CNAME points a name at another name, never at an IP address.
  • A name with a CNAME cannot hold any other record type (RFC 1034, RFC 2181).
  • The domain apex needs SOA and NS records, so a plain CNAME is not allowed there.
Try the dns lookupFree, live, no signup

What does a CNAME record look like?

Zone file syntax and the resolver chain
www.example.com.   3600  IN  CNAME  example.com.
shop.example.com.  3600  IN  CNAME  stores.example-shop.net.
; a lookup for shop.example.com follows the alias:
;   shop.example.com   CNAME  stores.example-shop.net.
;   stores.example-shop.net  A  192.0.2.44

What rules does a CNAME have to follow?

CNAME constraints from the DNS standards
RuleConsequenceSource
No other data on the same nameYou cannot add MX, TXT or A records to a name that has a CNAMERFC 1034, 3.6.2; RFC 2181, 10.1
Not at the zone apexexample.com itself must keep SOA and NS records, so use A/AAAA or an ALIAS recordRFC 1034; RFC 2181, 10.1
NS and MX targets must not be aliasesMail and nameserver hostnames need their own address recordsRFC 2181, 10.3
No loopsA CNAME chain that points back at itself is an errorRFC 1034, 3.6.2

How do you create a CNAME record?

  1. 01

    Get the target hostname

    Your service (website builder, CDN, shop platform) gives you a hostname such as stores.example-shop.net. Copy it exactly.

  2. 02

    Add a CNAME

    Type CNAME, name = the subdomain only (www, not www.example.com, in most panels), value = the target hostname. A trailing dot is optional in most panels.

  3. 03

    Clear conflicts

    Delete any A, AAAA, MX or TXT record on the same subdomain, or the provider rejects the CNAME.

  4. 04

    Verify

    Run nslookup -type=CNAME www.example.com 1.1.1.1 and confirm the target. Then check that the target resolves to an address.

Check the target, not just the alias

A CNAME can be correct while the site is down if the target no longer resolves. DNS monitoring keeps a history of record changes so a repointed or removed CNAME shows up in your alert queue.

Where are CNAME records used in practice?

www to the bare domain

The www host follows the apex, so only one address has to be maintained.

Hosted services

Shop, help desk and landing page platforms give you a target hostname and ask for a CNAME on a subdomain.

Certificate validation

Some certificate authorities and email services ask for a CNAME with a generated name to prove control of the domain.

CDNs

A CDN provides a hostname for your subdomain so it can steer visitors to a nearby edge location.

Common questions

What is a CNAME record used for?

A CNAME lets a subdomain follow another hostname, so when the target changes address you do not edit your own zone. Typical uses are www pointing at the apex, and subdomains pointing at hosted services.

Can a CNAME point to an IP address?

No. A CNAME value must be a hostname. To point a name at an IPv4 address use an A record, and for IPv6 use an AAAA record.

Why can I not add a CNAME on my root domain?

The root of a zone must hold SOA and NS records, and a CNAME cannot coexist with other data on the same name. Use an A record or a provider ALIAS/flattening feature at the apex.

Can I have MX records on a name with a CNAME?

No. Because a CNAME excludes all other records on that name, mail for that exact name would break. Put MX records on a name that has no CNAME, and point MX targets at hostnames with address records.

How long can a CNAME chain be?

DNS has no fixed limit, but every extra hop adds a lookup and a place to fail, and resolvers cap the number of hops they follow. Keep chains short, ideally a single CNAME to a name with address records.

Watch your DNS records for changes

Aepto keeps a history of every DNS record change per domain and alerts you on any change or only risky ones.