# A Records vs CNAME Records: What Is the Difference?

A records and CNAME records both help visitors reach a website, but they do it in different ways. An A record sends a hostname to an IPv4 address. A CNAME record sends a hostname to another hostname, which is then resolved by DNS.

That small difference matters when you connect a domain to hosting, a CDN, a SaaS product, or a load balancer. Choosing the wrong record can cause slow lookups, broken routing, SSL errors, or confusing migration behavior.

The short answer

- Use an A record when the hostname should point directly to an IPv4 address. - Use a CNAME record when the hostname should follow another hostname managed by a provider. - Avoid placing a CNAME at the root domain unless your DNS provider supports a special flattening feature. - Do not create long CNAME chains if you care about speed and reliability.

Use AccessTest DNS Lookup when you want to inspect the current answer for a domain:

https://www.accesstest.net/tools/dns-lookup/

What an A record does

An A record maps a hostname to an IPv4 address:

```txt example.com A 192.0.2.10 ```

When a browser asks for `example.com`, DNS returns the IP address. The browser can then connect to that server.

A records are common when:

- Your hosting provider gives you a fixed IP address. - Your root domain needs to point to a server or load balancer. - You manage the infrastructure yourself. - You want direct control over the destination IP.

The tradeoff is maintenance. If the provider changes the IP address, you must update the record.

What a CNAME record does

A CNAME record points one hostname to another hostname:

```txt www.example.com CNAME example.hosting-provider.com ```

The DNS resolver follows the alias and asks for the final A or AAAA answer. This is useful when a provider wants to manage the actual IP addresses behind the scenes.

CNAME records are common when:

- You connect `www` to a CDN or SaaS platform. - A hosting provider asks you to point to a managed hostname. - The destination IP may change over time. - You want the provider to handle routing changes for you.

The tradeoff is an extra lookup. In most cases this is acceptable, but long chains should be cleaned up.

Why CNAME at the root can be tricky

The root domain, such as `example.com`, usually needs records like MX, TXT, NS, and SOA. A normal CNAME cannot coexist with other records at the same name.

That is why many DNS providers offer features called ALIAS, ANAME, or CNAME flattening. These let you point the root domain at a hostname while still publishing normal DNS answers.

If your provider asks for a CNAME on the root domain, check whether your DNS host supports flattening before making the change.

Common mistakes

Mixing record types at the same name

Do not place a CNAME and an A record on the same hostname. A hostname that is a CNAME should not also have other ordinary records.

Creating CNAME loops

Avoid configurations where one hostname points back to another in a loop. DNS resolution will fail.

Leaving stale A records after migration

When moving hosting or CDN providers, old A records can keep traffic going to the wrong place. Check both the root domain and `www`.

Ignoring IPv6

A records are only for IPv4. If your site also publishes AAAA records for IPv6, test both paths. A broken IPv6 route can affect users even when IPv4 looks healthy.

Which one should you choose?

Choose an A record when you have a stable IP address and need direct routing. Choose a CNAME when a provider gives you a managed hostname and expects to control the final IPs.

For many websites, a common setup looks like this:

```txt example.com A 192.0.2.10 www.example.com CNAME example.com ```

For CDN-backed sites, it might look like this:

```txt www.example.com CNAME example.cdn-provider.net ```

The exact setup depends on your DNS provider, CDN, hosting platform, and whether the root domain is involved.

Migration checklist

Before changing A or CNAME records:

- Record the current DNS answers. - Lower TTL in advance if you need a faster migration. - Confirm whether the root domain supports flattening. - Check both `example.com` and `www.example.com`. - Test from more than one resolver and region. - Keep the old server available until cached answers expire.

FAQ

Is CNAME slower than A?

Sometimes slightly, because it may require another DNS lookup. The bigger problem is usually a long chain of aliases, not a single CNAME.

Can I use CNAME for email?

Not for MX routing itself. Email routing uses MX records. TXT records are also common for SPF, DKIM, and DMARC.

Should `www` be CNAME or A?

Both can work. If a provider gives you a managed hostname, use CNAME. If you control the destination IP, A records may be simpler.

What should I check after changing DNS?

Check the final A and AAAA answers, TTL, redirect behavior, SSL certificate coverage, and whether the website loads from different regions.