Netlify DNS CNAME records not working

Problem

Hi,

I am trying to point one of my subdomains (stg.groovly.fm) to a Netlify-hosted website (https://groovly-dev.netlify.app/) via a CNAME DNS record so that navigating to https://stg.groovly.fm is identical to navigating to https://groovly-dev.netlify.app/ but I get a 404 (not found) error from Netlify for the former, while the latter works fine.

Both ping and dig commands seem to succeed (see output below). Also none of my other CNAME records configured on Netlify’s DNS seem to work either.

Am I missing something here? Any ideas / help is appreciated!

DNS Config

  • Netlify site url: https://groovly-dev.netlify.app/
  • Top-level domain: groovly.fm (managed via Netlify DNS)
  • CNAME record config:
    • name: stg
    • value: groovly-dev.netlify.app
    • TTL: default

HTTP Error

  • Request URL: https://stg.groovly.fm/
  • Status Code: 404
  • Remote Address: 18.230.52.212:443
  • Referrer Policy: strict-origin-when-cross-origin

Command output for ping

$ ping -c 1 stg.groovly.fm

PING *groovly-dev.netlify.app* (18.230.52.212): 56 data bytes
64 bytes from 18.230.52.212: icmp_seq=0 ttl=46 time=43.220 ms

--- groovly-dev.netlify.app ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 43.220/43.220/43.220/0.000 ms

Command output for dig

$ dig stg.groovly.fm

; <<>> DiG 9.10.6 <<>> stg.groovly.fm
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30638
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;stg.groovly.fm.			IN	A

;; ANSWER SECTION:
stg.groovly.fm.		3600	IN	CNAME	groovly-dev.netlify.app.
groovly-dev.netlify.app. 20	IN	A	18.230.52.212

;; Query time: 142 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Thu Sep 24 11:19:47 -03 2020
;; MSG SIZE  rcvd: 96

Hi @martinzen! Welcome to netlify community.

Adding your custom domain to the site in our UI is the next step. You can do that right here: https://app.netlify.com/sites/groovly-dev/settings/domain#custom-domains.

Let us know how that goes!

Hi Laura, thanks for your answer.

The custom domain for the main site is already configured (groovly.fm) and working. All I’m trying to do is point a subdomain for the main site (dev.groovly.fm) via a CNAME record so that it points to another Netlify site (https://groovly-dev.netlify.app).

In summary:

I’m pretty sure the problem is at the Netlify content-serving level since the DNS seems to respond correctly as per my initial post.

Any ideas of what might be going on here?

Hi, @martinzen, there are two steps to getting this working.

One is adding the custom domain here:

I don’t see dev.groovly.fm added there yet. The other is to have DNS record in place and I don’t see that when I test:

$ dig dev.groovly.fm CNAME  +noall +answer

; <<>> DiG 9.10.6 <<>> dev.groovly.fm CNAME +noall +answer
;; global options: +cmd

Did you remove those now? If you want add those and troubleshoot this further, please let us know.

Hi Luke,

That doesn’t work unfortunately. My custom domain is already added to the main site (groovly.fm). When I try to also add the domain to the other Netlify site groovly-dev.netlify.app I get an error saying “Another site is already using this domain” which makes sense because it was added to the main site.

All I’m trying to do is have the main site’s Netlify-managed DNS point to the secondary site under an alias so that instead of having to navigate to https://groovly-dev.netlify.app/I can more conveniently navigate to dev.groovly.fm.

Please let me know if this is possible or if I ran into a limitation of Netlify’s DNS.

Hi, @martinzen, It should be possible to add “dev.groovly.fm” here:

https://app.netlify.com/sites/groovly-dev/settings/domain#custom-domains

If you try to add just groovly.fm there will be an error because that custom domain is already used on a different site on the same account. However, if you add the custom domain with the dev subdomain in front of it, that subdomain is not in use and should work.

If it does not, please let us know.

Hi Luke,

Thanks a lot, that worked, much simpler than I thought.

I was trying to add the top-level domain groovly.fm instead of the subdomain (api.groovly.fm). It would probably we useful to clarify this in the docs to avoid confusion.

Cheers,

What proposed changes would you make to the documentation, @martinzen? Happy to take your feedback to our documentation team, but my team is struggling to understand the shortcomings that you found in the docs, so some more explanation would be great to help us understand.

Thanks in advance!

Hi,

The docs clearly mention that it’s possible to point subdomains to other services which made me think that the way to achieve that was to point the secondary Netlify site (in my case, groovly-dev.netlify.app) to said subdomain (for me it was stg.groovly.fm) via manually adding a CNAME record to the primary site’s DNS config.

But it turns out that doesn’t work (I got a 404 from Netlify). Instead, the way to achieve it is to go to the secondary site, add the subdomain in there (clicking “yes” when asked if you owned the domain) and that would add the CNAME record onto the primary site’s DNS. Both approaches seem to produce the exact same DNS record, but the manual one just doesn’t work, not sure why.

I would suggest adding a paragraph explaining the (probably frequent) use case of having to point a subdomain to another Netlify site citing the steps described above by Luke.

Hope I didn’t miss anything. Thanks a lot for your great support.

Cheers,

Hmm, that’s odd, these instructions are correct:

The docs clearly mention that it’s possible to point subdomains to other services which made me think that the way to achieve that was to point the secondary Netlify site (in my case, groovly-dev.netlify.app ) to said subdomain (for me it was stg.groovly.fm ) via manually adding a CNAME record to the primary site’s DNS config.

Nowhere do those docs say “create a second site and put the hostname on it, to configure this hostname for the secondary service”

This workflow you describe next is not correct:

Instead, the way to achieve it is to go to the secondary site, add the subdomain in there (clicking “yes” when asked if you owned the domain) and that would add the CNAME record onto the primary site’s DNS.

The CNAME record should be created manually in the DNS UI if it is for a separate service. Applying the hostname to the site will cause a failure there.

So I guess I am still confused. Thanks again for your help!