Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 37 ยท Domains, HTTPS and Redirects

Custom Domains and DNS

Connect your own domain to Vercel or Netlify: apex versus www, A, CNAME and ALIAS records, nameserver delegation, propagation and how to debug a domain that will not verify.

Every deployment gets a free address such as my-app.vercel.app or my-site.netlify.app. That is fine for testing, but real visitors expect www.example.com. Connecting a custom domain means telling the Domain Name System (DNS) that your name should lead to the platform's servers, and telling the platform that it is allowed to answer for that name.

Vercel and Netlify cannot run inside this site, so nothing here is a screenshot or captured output. The menus and records are described from the products' documented behavior, and the runnable code is a small, clearly labelled DNS stand-in written in JavaScript. Exact IP addresses and target names change over time: always copy them from your dashboard.

What DNS does for your site

DNS is a phone book. A record maps a name to a value. The ones you will meet:

Type Maps Typical use
A name to an IPv4 address pointing an apex domain at a platform load balancer
AAAA name to an IPv6 address same, for IPv6
CNAME name to another name pointing www at cname.vercel-dns.com or my-site.netlify.app
ALIAS / ANAME name to another name, flattened to A records apex domains on providers that support it
TXT name to text ownership verification
NS zone to name servers delegating the whole domain

The apex (or root) domain is example.com with no prefix. A subdomain is anything in front of it, such as www.example.com or docs.example.com. DNS rules forbid a CNAME at the apex, because the apex must also hold NS and SOA records. So an apex needs an A record (or an ALIAS/flattened CNAME if your DNS host offers one).

Two ways to connect a domain

1. Point records at the platform (external DNS). You keep your DNS at your registrar or a provider such as Cloudflare. In the project's domain settings you add the domain, and the platform shows the records it expects: an A record for the apex and a CNAME for www. You create those at your DNS host.

2. Delegate to the platform's name servers. You change the domain's NS records at the registrar to the platform's name servers (Vercel and Netlify both offer this). The platform then hosts the whole DNS zone, and you edit records in its dashboard. This lets the platform issue wildcard certificates and manage records for you, but you must recreate any existing records (email MX, TXT) in the new zone first, or mail will stop.

Connect a domain

Add it Enter the domain in project settings.
Records Copy the A and CNAME values shown.
Wait DNS changes need time to spread.
Verify The platform checks and issues HTTPS.

Apex gets an A record. www gets a CNAME.

1 / 2

Apex, www and which one is primary

Most sites choose one canonical hostname and redirect the other to it. Both platforms let you add example.com and www.example.com to the same project and mark one as primary; the other is redirected automatically (a permanent redirect) to the primary. Pick one and stay with it, because search engines treat example.com and www.example.com as different sites. See Redirects and Rewrites for custom rules.

Propagation and TTL

Every record has a TTL (time to live): the number of seconds resolvers may cache the answer. If the old record had a TTL of 3600, some visitors keep seeing the old destination for up to an hour after you change it. Practical advice: lower the TTL a day before a migration, switch, then raise it again. "Propagation" is not a mysterious broadcast; it is just caches expiring at different moments.

Simulating a lookup

The stand-in below holds a tiny zone as data and resolves a name the way a resolver does: follow CNAME chains until it reaches an A record, and refuse a CNAME at the apex.

JS DNS resolver stand-in

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Checking a record list before you publish

Typos in DNS are the most common reason a domain stays "Invalid configuration". This second stand-in compares what you entered with what a project expects, and tells you what is wrong.

JS Expected records checker

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Debugging a domain that will not verify

  • Wrong host field. Many DNS dashboards want @ for the apex and www (not www.example.com) for the subdomain. Some append the domain automatically, giving www.example.com.example.com.
  • Old records left behind. A leftover A record next to your new CNAME makes answers inconsistent. Remove the old one.
  • Proxy in the way. If you use Cloudflare, an orange-cloud (proxied) record hides the real target from the platform's check, and can cause redirect loops with certificate modes. Start with DNS-only (grey cloud) until the platform shows the domain as valid.
  • CAA records. If you have CAA records that limit which certificate authorities may issue certificates, add the platform's authority or the certificate cannot be issued. See HTTPS and Certificates.
  • Waiting. If every record is right, wait for the old TTL to expire.

On a command line, dig example.com A +short or nslookup www.example.com shows what the world sees, which is more useful than what your dashboard says you saved.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why can you not put a CNAME record at the apex domain?

    A CNAME says this name is an alias for another name entirely, so no other record may exist beside it. The apex always has NS and SOA, so use A or an ALIAS-style flattened record.
  2. 2. What does TTL control?

    TTL is the cache lifetime in seconds. Lower it before a migration so old answers expire sooner.
  3. 3. What is a risk of delegating to the platform's name servers?

    Delegation replaces the whole zone. Copy mail and verification records across first.
  4. 4. Which is the safest first step when a proxied Cloudflare record keeps failing verification?

    A proxy hides the platform's target from its checker. Verify first, then decide whether to proxy.

Summary

  • A domain points to a deployment through DNS records: A for the apex, CNAME for subdomains.
  • You can keep DNS elsewhere and add records, or delegate the zone to the platform.
  • Choose one canonical hostname and redirect the other.
  • TTL explains why changes seem slow; check with dig or nslookup.
  • Typos, leftover records, proxies and CAA records cause most verification failures.

Next: HTTPS and Certificates