How to fix: Domain does not resolve to the GitHub Pages server. Error in Github Pages for custom domain setup with Enforce HTTPS Enabled?
Asked Answered
G

4

106

So I am trying to get a custom domain to work with my github pages user site. I have followed pretty much the standard procedure for doing this as follows: (recommended by github here too: https://help.github.com/articles/setting-up-an-apex-domain-and-www-subdomain/). Note I need both the apex domain (example.com) and the www subdomain (www.example.com) to resolve to my github pages user site at username.github.io (the website itself is a jekyll based blog and I have checked that it compiles successfully before I started this process)

  1. I added an A record to my DNS records at the registrar pointing to all of the four IP addresses provided by Github from the apex domain example.com:
  • 185.199.108.153
  • 185.199.109.153
  • 185.199.110.153
  • 185.199.111.153
  1. Next I went in and added a CNAME record for the www sub domain pointing to username.github.io
  2. And then I finally enabled the custom domain example.com under the settings tab of the repository (under Github Pages > Custom Domain), and also enabled the Enforce HTTPS option after it was enabled within about an hour.

I have tried contacting my registrar and they said that everything in the DNS record seem fine and they get the following results:

A records :

 example.com.            21460  IN      A      185.199.111.153
 example.com.            21460  IN      A      185.199.109.153
 example.com.            21460  IN      A      185.199.110.153
 example.com.            21460  IN      A      185.199.108.153

CNAME :

www.example.com.        7199    IN      CNAME  username.github.io.

As expected.

But I still get the following error in github (under the settings tab of the repository):

"**Domain does not resolve to the GitHub Pages server. For more information, see https://help.github.com/articles/setting-up-a-custom-domain-with-github-pages/.**"

And when I try to access the site by typing either example.com or www.example.com, the browser redirects to https://example.com/ and I get the error (on Chrome):

ERR_CONNECTION_REFUSED

Note that there is a warning on the documentation by github saying:

Warning: If your domain has HTTPS enforcement enabled, GitHub Pages' servers will not automatically route redirects. You must configure www subdomain and root domain redirects with your domain registrar.

I have no idea how to get around this. I suspect this is the possible cause of the issue. So a solution might be to circumvent this redirection, I just do not know how I would do this.

Gustav answered 6/1, 2019 at 6:32 Comment(6)
Just wait some time for DNS propagation and htpps://atifali.ca is working fine.Balzac
yep just realized that was the only issue. Thanks though!Gustav
@DavidJacquel I wonder how you actually got that domain address? Just curious since I tried making it as general as possible by removing any specific URLs.....was it a mere guess? Just curious hahaGustav
I'm a well trained investigator. Wen someone asks a too general question, making debuging impossible, I search. And usually, I start my search on the profile page. In your case it was easy. ;-)Balzac
Well @DavidJacquel I respect your level of commitment! We need more people like you in this world! Thanks mate :)Gustav
This question is a great canonical answer on how to set up github pages. In particularly the A record IPs are strikingly spread quite far in the documentation from how to set up CNAME.Unthinking
G
122

For anyone stumbling across this. Actually I realized I have outlined the correct method to set this up with Github Pages. And this is in line with what is recommended by Github as of today and works perfectly well. Just make sure you wait for the DNS Propagation to take effect which in some cases might take up to 24hrs. And this is what the problem was in my case.

Gustav answered 7/1, 2019 at 16:53 Comment(5)
Is there a way to know when the DNS settings have propagated?Cenac
@Cenac yes absolutely, you can check both the A and the CNAME records on websites like the following: whatsmydns.net, dnschecker.org, dnsmap.io and there are many more. Basically there is a timeout for these settings on servers I believe and in most cases its defaulted to 24hrs (I might be wrong though so be careful)Gustav
the DNS propagation is - if i understand correctly - governed by the "time to live" or TTL value, which essentially determines the lifespan of how long that DNS entry should be cached before a new one is requested. This value can be seen in the entry from your question (example.com. 21460 IN A 185.199.111.153) the TTL value is 21460 seconds (almost 6 hours). Waiting 24 hours is still ideal, but this is also a decent estimate for how long it will take before the cached version of your DNS entry on github's servers expires and a new (and updated) one is fetchedWallie
In my case the CNAME file I didn't have 'www' with the site. After I added It worked.Civilize
On Google domains I just added the 4 A entries, and they only took about 30 minutes to propagate. Maybe I got lucky.Cioffred
Y
38

Github shown me sucessive error message. After several iterations, github is happy with the following :

  1. In Settings > Pages :set up your github page :
    (you will have some error-warning message and Enforce HTTPS won't be ticked at first) enter image description here

  2. On my github repository's root, a CNAME file with the website name (with www):

www.example.com
  1. On my domain registration's DNS :
www                     28800  CNAME  MYUSERNAME.github.io.
@                       21460  A      185.199.111.153
@                       21460  A      185.199.109.153
@                       21460  A      185.199.110.153
@                       21460  A      185.199.108.153
  1. WAIT A DAY, ENJOY OUTDOOR WALK.

  2. The website is ok and in my terminal, a dig command returns :

$dig WWW.example.com +nostats +nocomments +nocmd
;WWW.example.com.   IN  A
WWW.example.com.    26728 IN CNAME  MYUSERNAME.github.io.
MYUSERNAME.github.io.   1527    IN  A   185.199.108.153
MYUSERNAME.github.io.   1527    IN  A   185.199.111.153
MYUSERNAME.github.io.   1527    IN  A   185.199.110.153
MYUSERNAME.github.io.   1527    IN  A   185.199.109.153
  1. Tick the "Enforce HTTPS".

Note: Replace example.com and MYUSERNAME by the values relevant to you.

Yeta answered 9/4, 2021 at 21:17 Comment(4)
"WAIT A DAY, ENJOY OUTDOOR WALK." - thanks for saving my sanity, this was the most important step. Even though the dig command already had a correct output for hours and my domain worked fine with github, the actual validation setting only started working after abound 20 hours.Confute
Thanks @Yeta I had missed adding 'www' in my CNAME as mentioned in step 2, it was configured ad the apex domain and thus wasn't working; adding 'www' fixed the problem.Branchiopod
Step 4 does not work. It says "command not found". What should I do now?Borough
"WAIT A DAY, ENJOY OUTDOOR WALK." 😂 thanks @r3verse, I will!Melanimelania
M
0

In my case, I update my index.html but my page doesn't have an update. After waiting for more than 36 hours, then I found that

Last deployed by @github-pages github-pages 8 months ago

So I change Build and deployment -> Source from Deploy from a branch to GitHub Actions, then change back.

My home page updated.

Merits answered 19/7, 2023 at 7:22 Comment(0)
A
0

Go to hostinger or anyother in CNAME change :

username.github.io to www.username.github.io

Change the domain name from

example.com to www.example.com

And go to code edit CNAME file and add both

www.example.com
example.com
Arad answered 27/4 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.