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.
- 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:
{ "name": "my-site", "routes": [ { "pattern": "www.example.com", "custom_domain": true } ]}Four common errors and how to fix them
Step 1: Conflicting A, AAAA or CNAME record in DNS
If an old Vercel, Netlify or registrar A/CNAME record still exists for
wwwor@, 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-runnpx wrangler deploy.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).
Step 3: Certificate stuck on "Pending Validation"
If your domain has restrictive
CAADNS records from a previous host, Cloudflare cannot issue its Universal SSL certificate. Allowletsencrypt.organdpki.googin your CAA records (or remove obsolete CAA records) and wait 2–5 minutes.Step 4: Apex domain (example.com) vs www
Pick one canonical host (either
www.example.comorexample.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.
Related articles
- DeployingDeploy an Astro site to Cloudflare WorkersA static Astro site needs no adapter: a four-line wrangler.jsonc and wrangler deploy. When pages render on request, add @astrojs/cloudflare. Both tested.
- DeployingDeploy Next.js to Cloudflare Workers: OpenNext or vinextTwo routes, both built and dry-run deployed on Next.js 16: OpenNext for the real Next.js build, vinext for new apps on Vite. Which to pick and the gotchas.
- DeployingAstro static vs SSR: when to use prerender or an adapterCompare static output, per-route prerender = false, and full server mode in Astro: when you actually need an adapter, CDN TTFB, and Cloudflare Workers.
Still stuck? We answer every message ourselves. Write to us