Step-by-Step Guide to Setting Up Custom Domains on Vercel via DNS
Setting up a custom domain on Vercel connects your production deployment to your own brand identity rather than a default .vercel.app subdomain. By configuring the correct DNS records with your registrar or DNS host, you point traffic directly to Vercel's global edge network while maintaining full control over your zone file. This guide walks you through the exact process of mapping your apex domain and subdomains to Vercel securely and reliably.
Prerequisites and Understanding Vercel DNS Requirements
Before you modify any zone files, you need a Vercel project deployed and access to your domain registrar's DNS management panel. Vercel supports two primary methods for connecting custom domains: apex redirection and direct configuration. Apex domains (like example.com) typically require an A record pointing to Vercel's static IP address or a CNAME setup if your DNS provider supports flattening (ANAME/ALIAS records). Subdomains (like www.example.com or app.example.com) always use standard CNAME records.
When you add a domain inside the Vercel dashboard under your project settings, Vercel inspects your current DNS configuration and provides specific record values. Before making changes, you can verify your existing entries using the CNAME Lookup tool on XiaTools to check current mappings, identify stale records, and ensure a clean migration path without downtime.
Step-by-Step Configuration Guide
Follow these sequential steps to map your custom domain to Vercel. Note that exact menu names in registrar panels may differ slightly depending on your provider (such as Cloudflare, GoDaddy, Namecheap, or Route 53), but the underlying DNS record types remain identical.
Step 1: Add the Domain in Vercel
- Log in to your Vercel dashboard and navigate to your project.
- Click on the Settings tab at the top of the project view.
- In the left sidebar, click on Domains.
- Enter your custom domain (e.g.,
example.comorwww.example.com) in the input field and click Add. - Vercel will prompt you to choose whether you want to redirect the apex to the
wwwsubdomain or vice versa. Select your preferred canonical URL structure.
Step 2: Configure DNS Records at Your Registrar
Vercel will display the required DNS records based on the domain type you entered. Log into your domain registrar's DNS management console and add the records specified below.
For Subdomains (e.g., www.example.com):
Create a CNAME record pointing your subdomain to Vercel's global routing target.
- Type:
CNAME - Name / Host:
www - Value / Target:
cname.vercel-dns.com - TTL: Automatic or 300 seconds
For Apex Domains (e.g., example.com):
Apex domains cannot natively host a CNAME record according to DNS specifications, though many modern DNS providers offer CNAME flattening (ALIAS or ANAME). If your provider supports alias records, use the CNAME target above. Otherwise, use Vercel's provided A record.
- Type:
A - Name / Host:
@(or leave blank for root) - Value / Target:
76.76.21.21 - TTL: Automatic or 300 seconds
| Record Type | Host / Name | Target / Value | Purpose |
|---|---|---|---|
| CNAME | www |
cname.vercel-dns.com |
Routes subdomain traffic to Vercel's edge network |
| A | @ |
76.76.21.21 |
Points apex domain directly to Vercel static IP |
| TXT | _vercel |
vc-domain-verify=example.com,abcdef... |
Proves domain ownership to Vercel |
Step 3: Verify Domain Ownership
If your domain is currently managed by another service or if Vercel requires validation, you may need to add a TXT record for ownership verification.
- Copy the TXT host and value provided in the Vercel dashboard.
- Add a new
TXTrecord in your DNS manager. - Paste the values and save the record.
Verifying Your DNS Setup
Once your DNS records are saved, propagation can take anywhere from a few seconds to 24 hours, though most modern DNS providers update within a minute. You can verify that your records are resolving correctly using command-line tools.
Run a dig command in your terminal to check the CNAME record for your subdomain:
dig CNAME www.example.com +short
Sample output:
cname.vercel-dns.com.
To verify the A record for an apex domain, run:
nslookup example.com
Sample output:
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: example.com
Address: 76.76.21.21
If you encounter SSL certificate provisioning delays, you can inspect the certificate status using OpenSSL:
openssl s_client -connect example.com:443 -servername example.com
Common Mistakes and How to Fix Them
Setting up DNS records can occasionally result in misconfigurations. Review these common pitfalls to ensure smooth operation:
- Conflicting A Records: Leaving old A records pointing to a previous hosting provider alongside your new Vercel records causes intermittent connection errors and split traffic. Always delete obsolete A and CNAME records.
- Cloudflare Proxy Status: If you use Cloudflare as your DNS provider, enabling the orange cloud (proxy) on your
cname.vercel-dns.comrecord can interfere with Vercel's automated SSL certificate issuance (Let's Encrypt HTTP-01 challenges). Set the proxy status to DNS Only (grey cloud) during initial setup, or switch to Vercel's Cloudflare integration. - Apex CNAME Errors: Creating a standard CNAME record for an apex domain (
example.com) violates DNS RFC standards and causes resolution failure at many resolvers. Use an ALIAS/ANAME record or Vercel's recommended A record instead. - Propagation Delays: Testing immediately after saving records can lead to false negatives due to local DNS caching. Flush your local DNS cache using
ipconfig /flushdnson Windows orsudo dscacheutil -flushcacheon macOS.
Quick Setup Checklist
- Added domain to project under Vercel Settings > Domains
- Created CNAME record for
wwwpointing tocname.vercel-dns.com - Created A record for apex domain pointing to
76.76.21.21(if applicable) - Added TXT verification record if requested by Vercel
- Disabled proxying (grey cloud) on DNS provider if using Cloudflare
- Verified record propagation using
digornslookup - Confirmed automatic SSL certificate generation in Vercel dashboard