Attempting to create CNAME to link subdomain to Fly deployment

Hello, and thanks for the help in advance! I’m trying to quickly test using a custom subdomain, e.g., tasks.mydomain.com, and linking it to my Fly.io deployment, e.g., myapp.fly.dev. In my fly.toml I’ve set [[services.ports]] handlers to http, so an https redirect shouldn’t be required. In GoDaddy (where I own mydomain.com) I’ve set a DNS CNAME record for Name: “tasks” with Value: “myapp.fly.dev.”. I can validate that the CNAME is set by running dig tasks.mydomain.com which shows a CNAME record pointing to myapp.fly.dev.

With the above, trying to visit tasks.mydomain.com in my browser returns a “ERR_CONNECTION_RESET” error. Am I missing a crucial step to get this subdomain working?

1 Like

Hi,

The first thing to check is that your app works at all, to rule out any issues with that (before looking at the custom domain). So load myapp.fly.dev and check that responds.

If so, then it sounds like Fly is simply not aware of your custom domain being pointed at that. And as such, when a request for tasks.mydomain.com arrives at Fly’s edge, it does not know where to route that (which app to send it on to). And hence you get an error.

You need to tell Fly about the existence of your custom domain or send a Host header. That is indeed the crucial step you reference. Generally telling Fly about the custom domain is the easier option (as sending a custom Host header involves using a proxy like a CDN). Take a look at this section, scroll down, and follow the suggested commands:

1 Like

Thank you so much for your response @greg! I can confirm that myapp.fly.dev works as expected.

I was still a bit stumped as I had seen those docs before, but I didn’t realize I needed to go through with the cert process listed here. Thank you for pointing me there! Everything is working as expected now.

3 Likes

Thanks, I also read the docs as saying the certs step applied only to the A record approach and not the CNAME approach

1 Like