beginner 10 min read

Connect Your Custom Domain to Cloudflare Pages

Step-by-step guide to connecting your domain to Cloudflare Pages.

By Solo Builder

You've built your site. Deployed it to Cloudflare Pages. Now you want your custom domain to point to it. Should be simple, right?

Except you hit a 522 error. Or your domain shows a parking page. Or it just times out. DNS is working but the site isn't loading.

Here's the complete guide to connecting your custom domain to Cloudflare Pages, based on real troubleshooting. No fluff, just the exact steps.

Prerequisites

Before starting, you need:

  • A domain registered (anywhere: Namecheap, GoDaddy, Spaceship, etc.)
  • A deployed Cloudflare Pages project
  • Access to your domain registrar's DNS settings

The Two-Part Setup

Most guides skip this, but there are two separate things you must configure:

  1. DNS Records - Point your domain to Cloudflare Pages
  2. Pages Custom Domain - Tell Cloudflare Pages to accept traffic from your domain

Missing either one causes errors. Let's do both.

This is the cleanest approach. Transfer DNS management to Cloudflare entirely.

Step 1: Add Domain to Cloudflare

  1. Go to Cloudflare Dashboard
  2. Click "Add a site" in the top right
  3. Enter your domain: yourdomain.com
  4. Click "Add site"
  5. Select "Free" plan
  6. Click "Continue"

Cloudflare will scan your existing DNS records.

Step 2: Review and Import DNS Records

Cloudflare shows your existing DNS records. Review them:

  • If you had email (MX records), they'll be imported
  • If you had www subdomain, it'll be there
  • Old A/CNAME records will show up

Click "Continue" to import them. Don't worry, we'll update them next.

Step 3: Get Your Cloudflare Nameservers

Cloudflare assigns you two nameservers. They look like:

amber.ns.cloudflare.com
greg.ns.cloudflare.com

Copy these. You'll need them next.

Step 4: Update Nameservers at Your Registrar

Go to wherever you bought your domain (Namecheap, GoDaddy, Spaceship, etc.):

  1. Log in to your registrar
  2. Find your domain
  3. Look for "Nameservers" or "DNS" settings
  4. Change from registrar's nameservers to "Custom nameservers"
  5. Paste the Cloudflare nameservers
  6. Save

This can take 15 minutes to 48 hours to propagate. Usually it's under an hour.

Step 5: Wait for Activation

Back in Cloudflare:

  1. Click "Done, check nameservers"
  2. You'll see a pending status
  3. Check your email - Cloudflare sends confirmation when it's active
  4. Or refresh the dashboard - it'll show a green banner when ready

Step 6: Configure DNS Records

Once active, go to your domain in Cloudflare → DNSRecords:

Delete any old A or CNAME records for your root domain and www.

Add these two records:

For root domain (yourdomain.com):

Type: CNAME
Name: yourdomain.com (or @)
Target: your-project.pages.dev
Proxy status: Proxied (orange cloud)
TTL: Auto

For www subdomain:

Type: CNAME
Name: www
Target: your-project.pages.dev
Proxy status: Proxied (orange cloud)
TTL: Auto

Click "Save".

Replace your-project.pages.dev with your actual Pages URL (like solobuilder-dev.pages.dev).

Step 7: Add Custom Domain to Pages Project

This is the step most people miss.

DNS points to Cloudflare, but Pages doesn't know to serve your site yet.

  1. Go to Workers & Pages (left sidebar)
  2. Click your project name
  3. Click "Custom domains" tab
  4. Click "Set up a custom domain"
  5. Enter: yourdomain.com
  6. Click "Continue"
  7. Cloudflare checks DNS and says "DNS records found" ✅
  8. Click "Activate domain"

Repeat for www:

  1. Click "Set up a custom domain" again
  2. Enter: www.yourdomain.com
  3. "Continue""Activate domain"

Step 8: Verify It Works

Wait 2-5 minutes, then visit:

  • https://yourdomain.com
  • https://www.yourdomain.com

Both should load your site with automatic HTTPS!

Option 2: External DNS (Alternative)

If you want to keep DNS at your registrar (not recommended, but possible):

  1. Don't change nameservers
  2. At your registrar, add these DNS records:

For root domain:

Type: CNAME
Name: @ (or yourdomain.com)
Target: your-project.pages.dev

For www:

Type: CNAME
Name: www
Target: your-project.pages.dev
  1. Then follow Step 7 above to add custom domains in Pages project

Note: You won't get Cloudflare's CDN, caching, or protection this way. Not recommended.

Common Errors and Fixes

Error 522: Connection Timed Out

Cause: DNS points to Cloudflare, but Pages doesn't know to serve your site.

Fix: Add the custom domain in Workers & PagesYour ProjectCustom domains.

Domain Shows Parking Page

Cause: Nameservers not updated yet, or DNS records not configured.

Fix: Check nameserver propagation at whatsmydns.net. Wait longer or verify nameservers are correct.

"Too Many Redirects"

Cause: SSL/TLS encryption mode is wrong.

Fix: Go to SSL/TLSOverview → Set to "Full" or "Full (strict)".

www Works But Root Doesn't (or Vice Versa)

Cause: Only added one custom domain to Pages.

Fix: Add both yourdomain.com AND www.yourdomain.com in Custom domains.

DNS_PROBE_FINISHED_NXDOMAIN

Cause: DNS records aren't propagated or are wrong.

Fix: Check your DNS records in Cloudflare. Verify CNAME targets are correct. Wait for propagation.

Email Security (Prevent Spoofing)

If you're not using email on this domain, prevent spammers from spoofing it:

Add SPF record:

Type: TXT
Name: @
Content: v=spf1 -all

Add DMARC record:

Type: TXT
Name: _dmarc
Content: v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s;

This tells email servers: "Don't accept emails from this domain - I don't send email here."

Verify Everything Works

Use these tools to confirm your setup:

DNS Propagation:

SSL Certificate:

  • Visit your site - should show 🔒 in browser

Performance:

Headers (check if proxied):

Why Use Cloudflare for DNS?

You could keep DNS at your registrar and just point to Pages. But here's why full Cloudflare is better:

Performance:

  • Global CDN (your site loads fast everywhere)
  • Automatic caching
  • Smart routing

Security:

  • DDoS protection
  • Free SSL certificates
  • Bot filtering
  • WAF (Web Application Firewall)

Features:

  • Email routing (forward emails for free)
  • Page Rules (redirects, caching rules)
  • Workers (serverless functions)
  • Analytics (privacy-friendly, built-in)

Cost:

  • All free for most sites
  • No bandwidth limits
  • Unlimited DNS queries

The Checklist

Bookmark this for next time:

  • [ ] Add domain to Cloudflare (if using full Cloudflare)
  • [ ] Update nameservers at registrar
  • [ ] Wait for activation (check email)
  • [ ] Add CNAME records in Cloudflare DNS
  • [ ] Add custom domains in Pages project (both root and www)
  • [ ] Verify both URLs load with HTTPS
  • [ ] Add email security records (SPF/DMARC)
  • [ ] Test with whatsmydns.net

Troubleshooting Checklist

Site not loading? Run through this:

  1. DNS propagation complete? Check whatsmydns.net
  2. Nameservers correct in registrar? Verify they match Cloudflare's
  3. DNS records correct? CNAME pointing to your-project.pages.dev
  4. Custom domain added in Pages? Check Workers & Pages → Custom domains
  5. Both root and www added? Need both if you want both to work
  6. SSL mode correct? Should be "Full" or "Full (strict)"
  7. Still broken? Clear browser cache or try incognito mode

Real-World Timeline

Realistic deployment timeline:

  • Nameserver update: 15 min - 24 hours (usually 30-60 min)
  • DNS record propagation: 1-5 minutes
  • SSL certificate provisioning: 1-2 minutes
  • Total: 30 minutes to 24 hours (usually under 1 hour)

Don't panic if it's not instant. DNS takes time.

Tips for Solo Builders

Start with Cloudflare Pages subdomain first: Before buying a domain, deploy to your-project.pages.dev. Make sure the site works. Then add the custom domain. Easier to debug when you know the site itself works.

Use Full Cloudflare: Don't half-ass it by keeping DNS at your registrar. Move it all to Cloudflare. You get better performance, security, and troubleshooting is simpler.

Don't skip www: Add both yourdomain.com and www.yourdomain.com as custom domains. Users type both. Both should work.

Test in incognito: Your browser caches DNS aggressively. When testing, use incognito mode or a different browser.

Bookmark whatsmydns.net: Best tool for checking if DNS changes have propagated globally.

The Most Common Mistake

Adding DNS records but forgetting to add the custom domain in the Pages project.

Your DNS can be perfect, but if Pages doesn't know to serve your site for that domain, you'll get a 522 error.

Always do both:

  1. DNS records in Cloudflare DNS
  2. Custom domain in Pages project settings

What If You Already Have Email?

Moving nameservers to Cloudflare won't break email if you import the MX records.

When Cloudflare scans your domain, it imports existing MX records. Just make sure they're there before confirming.

Or manually add them:

Type: MX
Name: @
Mail server: [your email provider's server]
Priority: [usually 10]

Check your email provider's docs for exact MX records.

Next Steps After Setup

Once your domain works:

  1. Submit sitemap to Google Search Console
  2. Set up analytics (Cloudflare Analytics is free and built-in)
  3. Configure redirects (e.g., www → non-www or vice versa)
  4. Set up email routing (forward emails to your personal address)
  5. Add monitoring (UptimeRobot, Checkly, or Cloudflare's built-in)

The Bottom Line

Connecting a custom domain to Cloudflare Pages is a two-step process that most guides oversimplify:

  1. Point DNS to Pages (via CNAME records)
  2. Tell Pages to accept the domain (Custom domains in project settings)

Do both, wait for DNS propagation, and you're live.

The confusion comes from older hosting where you just update DNS and you're done. With Cloudflare Pages, you explicitly add domains to projects. Once you know this, it's straightforward.

Now go ship your site on your own domain. You've got this.

Tags: cloudflarednshostingdeployment