DNS records explained: A, CNAME, MX and TXT for your website
A records point at your server, CNAMEs alias names, MX routes your email and TXT carries verification data. What each record does, and how to change them while limiting the risk of disruption.
You bought a domain, and now the registrar's DNS page wants record types you have never seen: A, CNAME, MX, TXT. Each one is a short instruction that tells the world how to reach a piece of your setup - your website, your email, or proof that you own the domain at all. This guide covers the record types a site owner actually edits, what each one points at, and the mistakes that take sites offline. For email authentication records specifically (SPF and DMARC policies as TXT records; DKIM keys as TXT or via CNAME delegation at some providers), see our separate guide.
What a DNS record is
DNS records are instructions that live in authoritative DNS servers, providing information about a domain, including which IP address it points to. When someone types your domain, their resolver walks those instructions to find your server. A domain without the right records is a name that points nowhere.
Records live at your DNS provider - often your registrar, sometimes a separate DNS host. Editing them in the wrong place is a common reason changes "do nothing": the provider shown in your domain's nameserver records is the one that answers queries.
A and AAAA: the address records
The A record is the most fundamental type: it maps a name to an IPv4 address, the number your hosting provider gives you. If your server has an IPv6 address, that goes in a separate AAAA record instead. Most small sites need at least one A record for the bare domain (example.com) so it reaches the web server. You can have several A records on one name - resolvers rotate through them - and a name can carry both A and AAAA records so IPv4 and IPv6 clients each get a usable address.
CNAME: the alias record
A CNAME record points one name at another name rather than at an IP address - for example, pointing www.example.com at example.com, or at a hostname your host assigns. One restriction matters: DNS rules (RFC 1034) say that where a CNAME record exists, no other data should exist at the same name. That is why a CNAME is generally not allowed on the bare domain, which must carry its own records such as SOA and NS. Several providers work around this with their own ALIAS/ANAME record or CNAME flattening at the apex; those are provider-specific mechanisms, not standard CNAME behaviour.
MX: the mail record
MX records say which servers accept email for your domain, with a priority number so senders know which to try first - lower numbers are preferred. If you move email to a provider like Google Workspace, changing MX records is the switch that delivers your mail there, and removing any stale MX records from an old provider matters, because senders will deliver to whichever server answers. Your website keeps working because A and MX are independent instructions.
TXT: the verification record
TXT records carry arbitrary text: email authentication settings (SPF and DMARC policies, and DKIM keys - published directly as TXT or delegated via CNAME at some providers) and verification strings from services that check domain control, like search consoles, live in TXT records. A name can hold many TXT records at once, which is how verification strings accumulate. The record carries the data; the checking service decides what it proves. Adding one rarely breaks anything; deleting one you do not recognize can silently break email delivery or unlink a service, so when a service asks you to add a TXT record, copy the host name and value literally.
TTL: why changes are not instant
Each record has a TTL (time to live) in seconds, which tells resolvers how long they may cache the answer. DNS "propagation" is not a push to the internet; it is old cached answers expiring. Before a planned migration, the standard move is to lower the TTL on the records you will change (to a few minutes) ahead of time, make the change, then raise it again. Until every cached copy expires, different users can legitimately see different answers, so plan cutovers for that overlap rather than a single switch moment.
Records you will see but rarely edit
- NS records name a zone's authoritative name servers. At the registrar, you set the delegation once, when you choose or change your DNS provider.
- The SOA record marks the zone's administrative metadata. A hosted DNS provider usually manages it for you; operators running their own zone files may edit it directly.
Mistakes that actually break things
- Putting a CNAME on the bare domain and finding the record rejected or mail broken - use the provider's apex-alias mechanism or an A/AAAA record instead.
- Leaving old records behind. After a host or email move, stale A, MX or TXT records keep sending traffic and mail to the old service.
- Editing at the wrong provider. Records only count where the NS records point; check which name servers the registrar lists before assuming an edit will do anything.
- Testing too early. A fresh change can look broken simply because the old answer is still cached; check the TTL before concluding the edit failed.
Changing records safely
A careful sequence for a move is: prepare and test the new destination first, without touching production DNS; then lower the TTL on the existing record and wait out the old TTL's length, so caches holding the previous answer expire; then update the record set, verify, and keep the old service running while caches drain, so you can roll back if something is wrong. Caches mean a change can take a while to be seen everywhere, so "it works for me but not for my colleague" is normal during propagation.
FAQ
Do I need both an A record and a CNAME for my site?
Not necessarily - that pairing is just one example: an A record for the bare domain plus a CNAME pointing www at it. What you actually need depends on how your hosting works: a provider may give you an IP address (A, or AAAA for IPv6), a hostname to alias, or a flattening-style record for the bare domain. Check what your host hands you before adding records.
How long do DNS changes take?
It depends on the TTL on the old record and on resolver caches, from minutes to many hours. Planning a change means checking the TTL first rather than expecting instant results.
Will changing MX records affect my website?
No - MX records only direct email. Your website traffic follows A and AAAA records, which are separate.
Is it safe to delete old TXT records?
Check what each one is for first. TXT records often hold email authentication and ownership verifications; removing an active one can break mail delivery or unlink services.
Sources
- Cloudflare Learning Center, DNS records: https://www.cloudflare.com/learning/dns/dns-records/
Record behaviour and provider features (such as apex aliasing) vary between DNS providers; confirm the exact record set your host and email provider publish before changing anything.