Skip to content

Cloudflare Workers custom domain not working: DNS and SSL fixes

Fix Cloudflare Workers custom domain errors: conflicting A/CNAME records, ERR_TOO_MANY_REDIRECTS with Flexible SSL, pending CAA validation and apex redirects.

Updated 3 December 2026Tested with
  • Wrangler 4.166.0
  • Cloudflare Workers

You attached a custom domain to a Cloudflare Worker, opened it in a browser, and hit ERR_SSL_VERSION_OR_CIPHER_MISMATCH, a 522/525 error, or a redirect loop. Most Cloudflare Workers domain failures come from mixing up Custom Domains with Routes, leaving an old DNS record behind, or setting the wrong SSL/TLS encryption mode.

Use a Workers Custom Domain (not a bare Route)

For a whole hostname like www.example.com or example.com, declare custom_domain: true in wrangler.jsonc. Cloudflare automatically creates the internal DNS record and provisions the edge SSL certificate:

wrangler.jsoncJSONC
{  "name": "my-site",  "routes": [    { "pattern": "www.example.com", "custom_domain": true }  ]}

Four common errors and how to fix them

  1. Step 1: Conflicting A, AAAA or CNAME record in DNS

    If an old Vercel, Netlify or registrar A/CNAME record still exists for www or @, adding a Workers Custom Domain either fails or routes traffic to the old host. Delete the old A/AAAA/CNAME record in Cloudflare Dashboard › DNS › Records and re-run npx wrangler deploy.

  2. Step 2: Redirect loop (ERR_TOO_MANY_REDIRECTS)

    Check SSL/TLS › Overview in Cloudflare. If it is set to Flexible, Cloudflare talks HTTP to an origin that redirects to HTTPS, looping forever. Always set SSL/TLS encryption mode to Full (strict).

  3. Step 3: Certificate stuck on "Pending Validation"

    If your domain has restrictive CAA DNS records from a previous host, Cloudflare cannot issue its Universal SSL certificate. Allow letsencrypt.org and pki.goog in your CAA records (or remove obsolete CAA records) and wait 2–5 minutes.

  4. Step 4: Apex domain (example.com) vs www

    Pick one canonical host (either www.example.com or example.com) and redirect the other with a Cloudflare Redirect Rule (301 permanent) so search engines don't index both copies.

Questions

Does my domain need to use Cloudflare nameservers?

Yes. Workers Custom Domains require the zone to be active on Cloudflare DNS (full setup). If you only need a subdomain on a non-Cloudflare zone, you would need Cloudflare for SaaS.

How do I deploy Astro or Next.js to Workers first?

Follow Deploy an Astro site to Cloudflare Workers or Deploy Next.js to Cloudflare Workers.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

Building with shadcn/ui and Tailwind CSS v4?

Install 188 free blocks and components with the shadcn CLI (no account), preview them in your own brand in Studio, or get all 1,570 blocks and every theme in UI Pro (€199 once).

Use it with

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components, included in UI Pro.