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 workers.dev 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 iambalaam.com
I’ve added the hello-world script to the route https://.iambalaam.com/
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 192.0.2.1 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 www.iambalaam.com gives the cloudflare page: Error 522: Connection timed out on www.iambalaam.com
and iambalaam.com gives my browsers error page iambalaam.com’s server IP address could not be found.

I have added routes:
https://*.iambalaam.com/* and https://iambalaam.com 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 example.com/* (nothing else leading or trailing)

1 Like

Amazing!

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

Thank you

1 Like