Skip to content
hostcomplex

A Record vs CNAME

Maarten Soetens 3 min read

A Record and CNAME Record Explained

A record vs CNAME comes down to one question: does a hostname point to an IP address, or to another hostname? An A record stores an IPv4 address directly. A CNAME record stores another name, and the resolver has to look that name up to find an address.

Both records answer the same visitor question, where should this name lead? The difference is where the final address is kept. With an A record, the zone owner holds the address. With a CNAME, the address belongs to whoever runs the target name, and the zone owner only maintains the pointer. For the basics of each type, see what an A record is and what a CNAME record is.

Trade-offs Between the Two Record Types

Each record type has strengths that matter in different situations:

  • Lookup speed: An A record answers in one step. A CNAME adds a lookup for the target. Resolvers cache both answers for the TTL set on each record, so the extra step is usually small.
  • Upkeep: A CNAME follows the target automatically. If a hosting platform changes its server addresses, a CNAME pointing to its hostname keeps working. An A record must be edited by hand.
  • Placement: An A record can sit at the bare domain, such as example.com. A CNAME cannot.
  • Coexistence: An A record can share a name with MX or TXT records. A CNAME must stand alone on its name.
  • Control: An A record shows the exact address you chose. A CNAME depends on the target name staying valid and pointing where you expect.

In short, use an A record when you control the address, need the bare domain, or must keep other record types on the same name. Use a CNAME when another party manages the address and you want your name to follow it.

A Shop That Uses Both Record Types

A small online shop runs its main site on a server with a fixed IP address. Its news section is hosted by a blogging service on servers the shop does not control.

For the bare domain, example.com, the owner adds an A record with the server's IPv4 address, since a CNAME is not allowed there. For news.example.com, the owner adds a CNAME that points to the hostname the blogging service provides. If the service later moves to new servers, the shop owner changes nothing, because the CNAME follows the new addresses. Had the owner used an A record for the news subdomain instead, every move by the blogging service would require an edit.

Frequently asked questions

Should I Use an A Record or a CNAME for www?

Either works. A CNAME for www that points to the hostname serving your site keeps www in step when that hostname's address changes. An A record for www with the same IP as the bare domain is also common and avoids the extra lookup. Whichever you choose, make sure both names reach the same site.

Is a CNAME Slower Than an A Record?

Slightly, in theory. A CNAME adds one lookup for the target name. Resolvers cache both kinds of answer for the TTL set on each record, so most visitors notice little difference. Speed should rarely decide the choice; placement and upkeep matter more.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.