Worker DNS setup

I am trying to write a worker that is publicly accessible from my domain. I have a ‘hello world’ worker that works in the online editor, but I’m having trouble understanding how to set up the DNS to be able to point to the worker.

The worker needs to be assigned to a route. That route will include a hostname and a path. Any visitor who hits that hostname/path will execute the worker.

Are you using the free workers plan with a domain, or did you add the $5/month Workers subscription to your plan?

1 Like

Thanks for looking into this.

I’m using the $5 plan and using the custom domain name
I’ve added the hello-world script to the route
In the testing and preview of the online editor it all looks good

I think I’m not understanding the DNS setup though

Do I need to add these records, and what IP do I use to route to the worker?

If the only function of that domain name is for your Worker, you’ll still need a DNS “A” record. You can use a dummy IP address, such as set to :orange:.

1 Like

Ah, that makes sense (as all requests willl be proxied, the IP won’t matter)

I have added these DNS records (and waited 10mins for propagation),

Now gives the Cloudflare page: Error 522: Connection timed out on
and gives my browsers error page’s server IP address could not be found.

I have added routes:
https://** and just to be sure.
But something’s still up with the connection. Do you know if there’s any documentation for this use case? Struggling to find any

For consistency and simplicity, I suggest that you redirect www to the non-www.

As far as the “address could not be found” error, it could be that your Route isn’t matching the url. If you’ve done the www redirect above, just make sure your route is* (nothing else leading or trailing)

1 Like


So the main confusion was the format of the routes in the worker. Changing it to* makes it work. I’m sure I can figure out sub-domains later if needed.

Thank you

1 Like

This topic was automatically closed after 31 days. New replies are no longer allowed.