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
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).
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.
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.
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.
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.
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.
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!
I completely agree with @martinzen here. I ran into exactly the same problem here. The docs are indeed misleading. Everything Martin said is accurate, including critique of the documentation.
TLDR:
Essentially, this whole problem boils down to an undocumented difference between how you map subdomains. If you are mapping a non-netlify website to your primary domain, you need to create a CNAME (as documented). If you are mapping another netlify website/app to your primary domain, you need to add a custom domain to the netlify website/app.
Just as Martin, I am using Netlify to deploy and manage DNS for both a main site and a secondary site I want to map to a subdomain. When trying to make a netlify.app connect to a subdomain at whateverApp.MainSite.com, you have to add whateverApp.MainSite.com as a custom domain on the app. Instead, the docs suggest that you should add a CNAME record within the DNS manager settings on MainSite.com. When you do this, as Martin said, you get a 404 and the subdomain mapping does not work, with no helpful error messaging.
To clarify an area that may be leading to this confusion. Where you, (@fool) say:
There is no separate service. Martin (and I) are both only using Netlify.
One other point that might be confusing is that Martin says that after adding the subdomain.MainSite.com to the netlify.app, it shows a new CNAME record on MainSite. Actually, when you go to your netlify console-> MainSite-> Domain Settings-> MainSite.com-> Options → DNS Settings and look at your DNS records, a new record shows up for ‘NETLIFY’, which is not a type you can pick if you ‘Add new record’. This is quite confusing and would be a welcome addition to the documentation.
Thanks for the feedback, but I disagree to some extent. The docs are correct in saying that you need to add a CNAME in your DNS Provider including if DNS is managed by Netlify. Regardless of who the DNS is hosting, what doesn’t change is you need to connect the domain to a Netlify site.
NETLIFY type records are nothing special, they’r A/CNAME records, but marking them as NETLIFY records helps you identify which one is added by Netlify and which is not.
Now in your case, after adding the CNAME entry inside Netlify DNS panel, if you had added the domain in site settings, it would still have worked. Adding the site to site settings is a compulsory step. Even when you add the domain to a site, that’s what the UI does, it adds a record automatically to the DNS Zone.
Was trying to get subdomain to work with Netlify for 2 days before I stumbled on this answer and finally got it to work.
I too feel the doc should be updated. I followed Configure External DNS, which only mentions about how we need to configure CNAME with our DNS provider (in my case, Cloudflare).
No where is it mentioned that the custom subdomain has to be added to Netlify’s domain (with the warning). If the doc had contained this information, I could’ve gotten it to work sooner.
I’m suggesting this so others don’t get stuck like I did
Thanks for this thread The documentation is not clear. I would recommend a screenshot of what domain settings we should be modifying and possibly some form validation when trying to add a CNAME to our netflify.app address. Even a tooltip of how you assign a NETLIFY DNS record with a link would be helpful.
just adding my 2c here, I also struggled to get this set up and could not understand why it wasn’t working. we have a domain registered with netlify DNS and i wanted to add a CNAME subdomain record to point directly to a deploy preview. This did not work until I added the subdomain to the site config domains as well and I could not find this mentioned anywhere (nor does it seem very intuitive).
This page also makes it seem as though there is no additional configuration needed outside of the Netlify DNS config: DNS records | Netlify Docs
edit: Nevermind, adding the DNS registration in the site domains actually just links it to the main (production) deploy. I don’t see a way to add a CNAME registration directly to a deploy preview. This could be accomplished sort of with branch deploys, but this takes some clicking around to accomplish for any branch we want this to happen for. I don’t understand why I can’t just add a CNAME record that points to a deploy preview URL. Similar to others, a dig on the CNAME record returns the proper deploy preview URL, however in the browser I get a netlify “Site not found” error