DNS records5 min read

CNAME vs A Record: Differences and When to Use Each

By DNSRadar

A records point directly to IPv4 addresses. CNAME records make one hostname an alias of another hostname. Both can direct users toward a service, but they behave differently during migrations, CDN onboarding and provider changes.

Quick answer

Use an A record for an IPv4 address you are expected to manage and CNAME for a supported hostname target. The alias and its target are cached separately. A correct alias does not prove that the target, TLS certificate or website configuration works.

Diagnostic checklist

  • Confirm whether the provider supplied an IP or a hostname.
  • Inspect the CNAME and every destination A/AAAA record separately.
  • Check apex and same-owner record restrictions before editing the zone.
  • Test HTTPS with the original hostname after verifying DNS.

Useful next checks

Choose the record from the value your provider supplies

An A record stores an IPv4 address. A CNAME stores another DNS name; address resolution then continues at that target. If your hosting provider supplies an IP you manage, A can be appropriate. If it supplies a managed hostname, use the supported alias configuration rather than copying an address that the provider may change.

AAAA is the separate record for IPv6. Publishing a correct A does not update an old AAAA. Neither A nor CNAME is an HTTP redirect: changing DNS does not change the URL shown in a browser.

Illustrative zone data: address and aliasdig
app.example.com. 300 IN A 192.0.2.20
www.example.com. 60 IN CNAME edge.example.net.
edge.example.net. 300 IN A 192.0.2.30

Resolve the alias and its destination as separate questions

The records above use reserved example names and addresses. They illustrate a lookup path, not current public DNS answers. Query CNAME to inspect the alias and A/AAAA to check where the destination resolves. A lookup for A at the original name can include the CNAME chain and the final address.

A valid alias whose target returns NXDOMAIN still produces a failed address lookup. A target with only IPv4 can legitimately return no AAAA data. Check the response status and complete chain before deciding that the original CNAME has failed to propagate.

Replace the sample owner and target with your owndig
dig @1.1.1.1 www.example.com CNAME +noall +comments +answer
dig @1.1.1.1 www.example.com A +noall +comments +answer
dig @1.1.1.1 edge.example.net A +noall +comments +answer
dig @1.1.1.1 edge.example.net AAAA +noall +comments +answer

The alias TTL and the target TTL expire independently

In the illustrative zone, the CNAME has TTL 60 and the target A has TTL 300. These are separate cached sets. Changing the CNAME target does not flush a previously cached alias; changing the target's address does not flush its cached A record.

When every resolver agrees on the CNAME but users reach different addresses, inspect the target's A/AAAA answers and any further aliases. If the provider uses geographic routing or load balancing, different address sets can be intentional. A common alias target alone does not establish identical application routing.

Why a standard CNAME cannot replace every apex record

A normal CNAME owner cannot also carry ordinary A, AAAA, MX or TXT data. The zone apex already needs SOA and NS records, so an ordinary apex CNAME conflicts with those requirements. DNSSEC-related records have protocol-specific exceptions; that does not allow mixing ordinary service records with a CNAME.

Some providers offer ALIAS, ANAME or CNAME flattening at the apex. These are provider features with their own behavior. A flattened response can contain synthesized A/AAAA records rather than an externally visible CNAME. Check the provider documentation and the actual authoritative output before treating a missing CNAME response as an error.

Pointing a CNAME at an IP

Use a hostname as the alias target; an IPv4 address belongs in an A record.

Keeping a verification TXT at the same CNAME owner

Choose the placement required by the service or change the record design; adding both ordinary records at the same owner is not a valid workaround.

Copying one CDN address into an A record

The address may change or depend on the lookup location. Follow the supported configuration from the CDN.

A migration check that includes the application

First confirm that the new service accepts the original hostname and has an appropriate certificate. Inspect the proposed target and check its addresses. Lower the relevant TTL before the planned cutover when you control it, and preserve the previous service during the transition.

After publishing, compare the alias on every authoritative server and then on independent recursive resolvers. Test HTTPS using the original hostname so both the HTTP Host and TLS server name are checked. A successful DNS lookup cannot prove the virtual host, certificate or application routing is correct.

Read-only checks; replace all example valuesdig
dig @ns1.example.net www.example.com CNAME +norecurse +noall +comments +answer
dig @8.8.8.8 www.example.com A +noall +comments +answer
curl -I https://www.example.com/
curl --resolve www.example.com:443:192.0.2.30 -I https://www.example.com/

What to do when the CNAME agrees but the website does not

If all resolvers return the intended alias, follow the remaining chain. An old target address suggests a different cache entry; SERVFAIL needs resolution or validation investigation; an HTTP error after successful DNS points to the service layer. Capture the owner, full target, address answer, resolver IP and check time.

DNSRadar can compare CNAME, A and AAAA separately and export the observed answers. It does not configure your CDN, validate the entire DNSSEC chain or test HTTPS for you. Keep those checks in the migration plan.

Sources and editorial approach

Technical documentation by DNSRadar. Examples using example.com and documentation addresses are illustrative; adapt commands to your zone and compare authoritative answers before changing production.

How we measure and the tool's limitations · Report a correction

Related DNS guides