DNS RECORDS EXPLAINED

A Record vs CNAME: Differences and When to Use Each

Compare A and CNAME records, choose between an IP address and hostname target, and understand apex domains, www, flattening and common DNS mistakes.

An A record points a DNS name to an IPv4 address. A CNAME record makes one DNS name an alias of another DNS name. If a service gives you an IPv4 address, it may expect an A record. If it gives you a hostname, it may expect a CNAME. Follow the service’s instructions because apex domains, email records and provider-specific alias features introduce important constraints.

Both record types can participate in getting a visitor to a website, but neither configures the website itself. DNS does not install a TLS certificate, add a custom domain to a hosting account or redirect a browser to a different URL.

A record versus CNAME at a glance

Question A record CNAME record
What does the value contain? An IPv4 address Another DNS name
Illustrative value 192.0.2.10 target.service.example.
Does it directly specify an address? Yes No; the target must be resolved
Can it be used at a zone apex? Yes A standard CNAME conflicts with required apex data
Can ordinary MX or TXT records share the same owner name? Yes Generally no

The addresses and service names in this article are documentation examples, not settings for a real host. Use the exact values provided by your hosting or service account.

How an A record works

This illustrative record maps www.example.com to an IPv4 address:

www.example.com.  300  IN  A  192.0.2.10

The record owner is www.example.com, the TTL is 300 seconds, and the address is the record’s data. If the intended address changes, the published A record needs to change unless your DNS provider automates that update.

An AAAA record performs the corresponding role for IPv6. A and AAAA are independent record types. When investigating inconsistent website access, check both: some clients may use a working IPv4 destination while others try an outdated IPv6 destination.

Multiple A records can exist at one name, but simply adding addresses does not create health checks or guarantee failover. The hosting and DNS design must support the behavior you want. A DNS answer is also not proof that an application at that address is accepting connections.

How a CNAME record works

A CNAME places an alias at a name:

www.example.com.  300  IN  CNAME  customer.service.example.

When an address is needed, resolution can continue at the target. That target may have A and AAAA records or another alias. This lets a service manage its destination addresses behind a stable hostname rather than asking every customer to maintain the same IP list.

The target is a DNS name. It is not an IP address, https:// URL, path or port. Entering https://customer.service.example/login as CNAME data confuses web routing with DNS.

Long alias chains add dependencies and complicate troubleshooting. A loop cannot produce a useful final answer. If the alias resolves but the target fails, the problem may be at the target’s DNS configuration rather than in your own CNAME value.

Why a standard CNAME is different at the root domain

The zone apex is the top of a particular zone, often example.com. It must publish SOA and NS information. A standard CNAME owner cannot also hold ordinary data such as those records, which is why a normal apex CNAME is not interchangeable with an A record.

The restriction applies to the same owner name. A CNAME at www.example.com does not stop example.com from having MX and TXT records. A CNAME at a hostname that itself needs mail or verification data creates a different problem because those records would need to coexist at that exact hostname.

RFC 2181, section 10.1 describes CNAME exclusivity, including the DNSSEC-related context. Cloudflare’s same-name record troubleshooting shows how a provider can enforce these restrictions in its editor.

What about ALIAS, ANAME and CNAME flattening?

Some providers offer features that let an apex follow a hostname while serving address records to clients. These are provider features, not permission to publish an ordinary apex CNAME alongside SOA and NS.

Cloudflare calls its feature CNAME flattening. Other products use different names and behavior. Consult your provider before assuming that an ALIAS, ANAME or flattened entry will appear as a CNAME in a public lookup.

This matters when checking results: an editor can show an alias-like configuration while the public answer contains A or AAAA records. An empty CNAME result at that name is not enough to prove the provider’s feature is broken.

How to choose the correct record

Changing an address or alias is different from moving authoritative DNS hosting. Review nameservers versus DNS records before replacing delegation when a record edit may be sufficient.

Use the service’s domain setup instructions as the starting point:

  1. Identify the exact hostname. The apex and www can require different records.
  2. Identify the supplied target. An IPv4 address fits A data; a DNS name can be a CNAME target where that record is allowed.
  3. Check existing data at that name. A name that needs MX or TXT records cannot simply become an ordinary CNAME owner.
  4. Confirm apex support. If the service supplies a hostname for the apex, check whether the host supports your DNS provider’s alias feature or provides another supported method.
  5. Configure the custom domain at the destination service. DNS alone does not make that service recognize your hostname.

Do not replace a service-managed hostname with an address you happened to observe in a lookup. That address may be temporary, location-dependent or part of a proxy network. Bypassing the documented target can break future updates.

Check A and CNAME records without confusing the answers

In the Bulk DNS Checker, enter both example.com and www.example.com, select A, AAAA and CNAME, and run the batch. Each name/type pair is a separate question.

An A query for an alias can involve a CNAME chain before the resolver obtains addresses. DNSBatch displays matching A records for the A result and the alias records when you request CNAME. Do not conclude that a hostname has a directly configured A record solely because an A lookup eventually returns an address.

Equivalent terminal queries are:

nslookup -type=A www.example.com 1.1.1.1
nslookup -type=AAAA www.example.com 1.1.1.1
nslookup -type=CNAME www.example.com 1.1.1.1

For diagnosis, record the queried name, type and resolver. If you compare two providers, run the same questions for both and preserve the answers. More examples are in the nslookup guide.

A CNAME does not redirect a website

Suppose www.example.com is a CNAME for a hosting provider’s hostname. A browser visiting https://www.example.com/account still requests your hostname and path. It does not automatically replace the address bar with the CNAME target.

The destination must accept requests for www.example.com and present a suitable certificate for HTTPS. A redirect between example.com and www.example.com, or from HTTP to HTTPS, is an HTTP-level configuration at your host, proxy or CDN.

This distinction helps diagnose a common sequence: the DNS answer is correct, but the browser shows a certificate error, a default hosting page or an unexpected redirect. Those symptoms require checking the destination configuration as well as DNS.

Common mistakes when changing records

Leaving an outdated AAAA record behind

Changing A while leaving an obsolete AAAA value can produce different outcomes for IPv4 and IPv6 clients. Compare both record types against the service’s intended configuration.

Removing mail records to make room for a CNAME

Deleting MX or SPF TXT data to satisfy an editor’s same-name restriction can disrupt email. Revisit the hostname and supported apex approach instead. The MX guide explains why mail routing is a separate concern.

Treating TTL as an immediate refresh command

Lowering a TTL after a change does not rewrite already cached answers. Plan migrations in advance and compare resolver snapshots. See DNS propagation and caching before repeatedly changing a record to chase a cached result.

Common questions about A and CNAME records

Is CNAME always better than an A record?

No. The right type depends on the hostname, the service’s supported setup and who manages destination changes. A provider-supplied IP can be the correct A value, while a provider-supplied alias can be the correct CNAME value for a subdomain.

Can one hostname have both A and CNAME records?

A standard CNAME cannot share its owner name with ordinary A data. Use the service’s supported configuration rather than publishing both to see which wins.

Does a correct DNS result prove the website works?

No. It verifies a resolver’s answer to a DNS question. HTTP routing, application health, connectivity and TLS still need their own checks. Use the record-type reference to connect each DNS result to the next useful investigation.