Your web host gives you either an address such as 192.0.2.10 or a hostname such as edge.example.net. That difference usually tells you what to enter in your DNS dashboard. Use an A record when your host tells you to point a name to an IPv4 address. Use a CNAME when it tells you to alias a subdomain to another hostname.
The root domain is the important exception to check. If your provider supplies a hostname for example.com itself, confirm which root-domain option your DNS provider and web host support before making the change.
CNAME vs A record at a glance
| Question | A record | CNAME record |
|---|---|---|
| What goes in the value field? | An IPv4 address, such as 192.0.2.10 | A hostname, such as edge.example.net |
| Where can you use it? | At the root domain or a subdomain | Normally at a subdomain. Root-domain options depend on the DNS provider. |
| What happens if the target IP changes? | Update the A record if the host assigns a different IP. | The alias can keep pointing to the same hostname as its addresses change. |
| Can it coexist with other records at that name? | It can coexist with records such as AAAA or TXT. | A standard CNAME generally cannot share its name with other record data. |
An AAAA record serves the IPv6 equivalent of an A record. If your host supplies an IPv6 address, follow its AAAA instructions. Enter hostnames and IP addresses as provided. Leave out https://, slashes, and page paths. Cloudflare’s zone apex guide
Which record should you use for your website?
Root domain with an IPv4 address from your host
If your host tells you to point example.com to an IPv4 address, use the A record it specifies. Many DNS dashboards display the root domain as @. Check whether your provider expects @, a blank name, or the full domain.
If you are replacing an old address, review existing A and AAAA records for that exact name. Keeping an old A record alongside a new one can cause some requests to reach the old destination. An outdated AAAA can send IPv6 traffic elsewhere. Keep multiple addresses only when the host calls for them.
www or another subdomain with a hostname from your host
If your website platform says to connect www.example.com to edge.example.net, create the CNAME for www with the supplied hostname as the target. The same pattern can apply to a name such as shop.example.com.
If an A or AAAA record already exists for that exact subdomain, check what uses it before replacing it. A conflict for www concerns records at www.example.com. The A record at example.com is a separate entry. Cloudflare’s guide to conflicting records
Root domain with a hostname from your host
A standard CNAME cannot normally be used at the zone apex because that name already needs records such as NS and SOA. Some providers offer a feature that lets you configure a hostname target while publishing address answers. Cloudflare calls its implementation CNAME flattening. Other providers may offer ALIAS or ANAME with their own restrictions.
Check both companies’ documentation. If your DNS dashboard does not offer a compatible apex option, ask the host whether it provides an A record or supports a www setup with a separate root-domain redirect. Avoid copying the current IP of a provider hostname into an A record unless the host specifically instructs you to use that address. It could change. Cloudflare’s CNAME flattening guide
Worked example: connect example.com and www
Imagine a host gives you an IPv4 address for the root domain and a hostname for www. These values are illustrative. Use the values provided for your own site.
| Name in dashboard | Type | Example value | Purpose |
|---|---|---|---|
@ | A | 192.0.2.10 | Connects example.com to the host’s IPv4 address |
www | CNAME | edge.example.net | Aliases www.example.com to the platform’s hostname |
Both names also need to be configured in the hosting platform as instructed. If your preferred public URL is https://example.com, set the redirect from https://www.example.com through the host or CDN. A CNAME helps the browser find the service. The redirect changes the URL the browser displays.
How to check the change before you move on
- Identify the live DNS provider. Confirm that the dashboard you’re editing serves the domain’s delegated nameservers.
- Save the old values. Record each affected name, type, target, TTL, and any proxy setting. Keep unrelated email and verification records in place.
- Check the exact name you edited. Use a public DNS lookup. If you see an old answer, compare it with the authoritative nameserver’s answer to distinguish caching from a change that has yet to be published.
- Account for proxying and flattening. A provider may return an address in public DNS even when the dashboard shows a CNAME-style entry. Check the configured target and the provider’s expected public behavior. Cloudflare’s CNAME setup guide
- Test both URLs in a browser. Open the root and
wwwover HTTPS. Confirm that each loads the intended site or redirects to it, and check for certificate warnings.
If the DNS answer is correct but the wrong site opens, review the custom-domain mapping on the hosting platform. If only one version fails, compare the root and www records, certificates, and redirect settings separately.
Frequently asked questions
Can an A record and a CNAME coexist on the same domain?
They can coexist at different names. For example, use an A record at example.com and a CNAME at www.example.com. An ordinary CNAME and an A record cannot occupy the same exact name.
Can I use a CNAME to redirect to a specific page?
A CNAME points to a hostname. Use an HTTP redirect from your host, CDN, or forwarding service to send visitors to a specific URL or path.
Is one record type faster?
A standard CNAME can add a DNS lookup step, but caching and provider features affect what a visitor experiences. Choose the supported record for your host’s target before making a decision based on speed.
Do I have to set up both www and the root domain?
Configure both if you want visitors who type either name to reach the site. Verify HTTPS for both and set a redirect if you want one preferred address.
Can changing my website records affect email?
It can if an email service depends on the name you change. Check whether the MX destination or any mail-related hostname resolves through the root or subdomain you plan to edit. Preserve unrelated email records and test sending and receiving after a migration.
Conclusion
Start with the value your web host supplies. An IPv4 address belongs in an A record, and a hostname typically belongs in a CNAME for a subdomain. If the hostname is for the root domain, confirm which apex setup both providers support. Finish by testing DNS and HTTPS for every name visitors use to reach your website.


