til/wrangler-routes-turn-off-workers-dev.mdtil
date
2026-11-10
tags
[cloudflare]

TIL

Adding a custom domain in wrangler.jsonc turns off the workers.dev URL

I deployed this site as a Worker with static assets and gave it its domain in config:

"routes": [{ "pattern": "imtoanle.com", "custom_domain": true }]

The deploy succeeded, and imtoanle-blog.<account>.workers.dev started answering with error 1042. Once routes is set, Wrangler treats workers_dev as false unless you say otherwise, and the next deploy turns the workers.dev URL off. The API confirmed it: the Worker’s subdomain setting read enabled: false.

If you want both addresses, say so:

"workers_dev": true,
"routes": [{ "pattern": "imtoanle.com", "custom_domain": true }]

Keeping it on is harmless when every page sets a canonical URL to the real domain.

The other half: “could not resolve host”

The custom domain looked broken too, and wasn’t. custom_domain: true makes Cloudflare create the DNS record and certificate on deploy. But I had been polling the domain before that record existed, so my machine cached the “no such host” answer. Cloudflare’s own name servers, 1.1.1.1 and 8.8.8.8 all returned the right address while my laptop still failed.

When a fresh custom domain “doesn’t resolve”, ask a public resolver before debugging anything else:

dig +short @1.1.1.1 example.com
resolvectl flush-caches   # systemd-resolved; browsers may keep their own cache too

↑↓ select ↵ open esc close