DEV Community

Stacy Montemayor
Stacy Montemayor

Posted on

Looking for help fixing github-hosted custom domain's CNAME

TLDR: I am super new to front end dev and have just published my first website (yay!). The trouble is that when you type www at the beginning of the url, the website is not loaded (IP address cannot be found).

The whole story: The website - without the www subdomain (i.e.: example.com) loads just fine, but www.example.com gives me server IP cannot be found.

What I have set up: Over on google domains, I have a "www CNAME username.github.io/respositoryname." set up. And on my github repository, I have a CNAME set up. Right now the CNAME file has only example.com listed. I have also edited and tested it with these options:

  1. example.com
  2. www.example.com

and

  1. www.example.com
  2. example.com

All three ways have not been successful.

Setting up all of this is all very new to me, and I've googled exhaustively last night and today. Everything I read says that one of these three ways to write my CNAME should have worked. I'm at a deadend now, any suggestions or further reading would be very welcome!! Thank you!!

Top comments (4)

Collapse
 
chuck_ha profile image
Chuck Ha • Edited

You can't have multiple domains in the CNAME file in github: help.github.com/articles/troublesh...

I think the problem is with the CNAME record in google domains. You want it to point to username.github.io. without the /projectname. That way, if you go to www.example.com the DNS record will redirect you to example.com and you should be good to go 👍🏼

note that DNS propagation can be slow so it might take some time!

Collapse
 
stacy profile image
Stacy Montemayor

hmmm... I thought the "www" was a subdomain?? Also, if I don't list the repository name in the google CNAME, how would it know to point to this particular repository? (I have one other repository set up to be hosted with github pages, but don't have an actual website there yet.)

I'm kind of thinking I might do a subdomain redirect on google domains where I redirect example.com to example.com It feels kind of hacky but I think it would work.

Collapse
 
chuck_ha profile image
Chuck Ha

www is a subdomain. Yeah, your suggestion would work. Otherwise, I'd probably get rid of the CNAME file entirely and follow help.github.com/articles/setting-u... this very closely. Good luck!

Thread Thread
 
stacy profile image
Stacy Montemayor

I dropped the repository name on google and it worked! I don't really understand why, but expect one day three weeks from now I'll actually understand. Thank you thank you!!