Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
  2. Next I went in and added a CNAME record for the www sub domain pointing to username.github.io
  3. 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.

like image 982
Atif Ali Avatar asked Jan 06 '19 06:01

Atif Ali


People also ask

How do I link my domain to GitHub Pages?

On GitHub, navigate to your site's repository. Under your repository name, click Settings. In the "Code and automation" section of the sidebar, click Pages. Under "Custom domain", type your custom domain, then click Save.

Does GitHub Pages support custom domain?

You can customize the domain name of your GitHub Pages site. GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

How do I redirect a domain to GitHub?

On your site's repository, click the settings tab . Under custom domain, type your custom domain and save. GitHub will automatically create a commit with a CNAME file at the root of your repository. Visit the dashboard provided by your domain provider and add a CNAME record pointing to your subdomain.


1 Answers

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.

like image 100
Atif Ali Avatar answered Sep 20 '22 11:09

Atif Ali