Netlify DNS CNAME records not working

Hi, @paul.mourer. This is indeed a feature request. There is a similar topic about this here:

You can use custom domains for branch deploys. However, at this time, there is no way to use a custom domain to view the deploy preview URLs.

About this:

I don’t understand why I can’t just add a CNAME record that points to a deploy preview URL.

The explanation is that DNS records do not and never have determined what website Netlify will show. Web servers don’t even look up the DNS records (only the client browser does). DNS records mean nothing to the server responding as they never see those records.

The DNS records point a domain to IP addresses that Netlify controls. That is all the DNS records do and nothing else.

For the HTTP request itself, the web server only examines the host HTTP request header to decide what site to show. DNS matters not at all. The only consideration is the host request header.

This is why creating the DNS record didn’t do anything. In order for this to function correctly, there are two requirements:

  • the DNS record for the deploy preview subdomain under the custom domain must be created
  • internal logic must exist in the web server that will interpret the subdomain as a deploy preview reference and then redirect to the correct deploy for the deploy preview (which is a feature request and not possible currently)

You had met the first requirement above by manually creating the DNS record. However, as no such internal logic exist currently, the second requirement was not met. This resulted in the HTTP request returning a 404. Again, this is because DNS itself has nothing to do with the site shown.

There is an open feature request to add this ability, however. I do not have an official ETA of if or when this will become possible.

Thanks for the explanation @luke - I was trying to think through how this works, this is all a bit more complicated than previous use cases I’ve had for a CNAME record on small web servers. I’ll add a +1 on that feature request. Thanks again!

thanks so much @paul.mourer

1 Like

Hello there.

I’m really lost now.

Followed the docs step by step…

Do I first add the sub-domain? I can’t add the CNAME to Hostinger.

I’m really stuck. Subdomain taxes.akillix.com

Do I have to delete the A record on Hostinger?

Site taxes.akillix.com

Hi, @patra0o. The instructions for this are found here:

Would you please tell us exactly what steps you have taken and what the results were?

Thanks Luke. Funny enough, I figured it out already a few hours ago.

Previously I:

  • Created the subdomain on Hostinger with all the A records, MX records and AAAA records being created automatically.
  • I then tried adding the subdomain to Netlify where it would tell me the apex domain was already added.
  • After that I would then forcefully try and add the CNAME record I get from Netlify to Hostinger which kept showing an error that the record confilicts with other DNS Records at the DNS Zone Editor.

Corrective action instead was:

  • Delete all the subdomain records from Hostinger,
  • Matter of fact, I wasn’t even supposed to create the subdomain on Hostinger
  • To register the external DNS all I had to do was add the Netlify CNAME DNS record to the Zone Editor and that is it, problem solved.
  • After waiting a few hours the SSL cert kicked in.

Boom, there went two days of debugging and accidentally taking down my main domain (during midnight hours luckily).