Troubleshooting GitHub Pages HTTPS: When Your Custom Domain Certificate Gets Stuck in 'New'
Deploying a website with GitHub Pages and a custom domain offers a fantastic, free hosting solution. However, one common hurdle developers encounter is ensuring HTTPS works flawlessly across all subdomains. A recent discussion on GitHub's community forum highlighted a classic scenario: an HTTPS certificate for a custom domain getting stuck in a 'new' state, leading to certificate errors for visitors.
The Challenge: A Stuck Certificate for www
The user, annalogofdesign, reported that their GitHub Pages site, annaskopenko.com, had its HTTPS certificate for the www subdomain stuck in 'new' for over a day. While the apex domain (annaskopenko.com) worked fine with its own certificate, www.annaskopenko.com was serving the default *.github.io certificate, resulting in an ERR_CERT_COMMON_NAME_INVALID error. Despite correctly configuring A records for the apex and a CNAME for www pointing to annalogofdesign.github.io, and even attempting to remove and re-add the custom domain, the issue persisted.
The DNS Detective Work: Uncovering the Proxy Problem
Enter JuanTorchia with a crucial insight. Through careful software monitoring of DNS resolution, it was discovered that while the apex domain's A records were correctly set to 'DNS only' (meaning they pointed directly to GitHub's IPs), the www CNAME record was being proxied through Cloudflare (indicated by the 'orange cloud' status). This meant public resolvers were getting Cloudflare's IP addresses instead of GitHub's when querying www.annaskopenko.com:
$ dig +short www.annaskopenko.com
104.21.71.100
172.67.144.96
This proxying prevented GitHub from successfully validating the domain and issuing a new certificate that covered both annaskopenko.com and www.annaskopenko.com. GitHub's certificate issuance process requires direct access to the domain's DNS records to verify ownership and control. When Cloudflare proxies the traffic, it essentially acts as an intermediary, serving its own certificate and obscuring the underlying GitHub Pages server from the certificate authority.
The Fix: Reconfiguring Cloudflare for Seamless HTTPS
The solution involves a straightforward adjustment in Cloudflare to allow GitHub to properly validate the www subdomain. This is a critical piece of development activity when integrating third-party services.
- Disable Cloudflare Proxying for
www: In your Cloudflare dashboard, navigate to DNS → Records. Find the CNAME record forwww.annaskopenko.com(which points toannalogofdesign.github.io). Click Edit and switch the Proxy status from 'Proxied' (orange cloud) to 'DNS only' (grey cloud). Save your changes. Leave the apex A records as they are. - Verify DNS Resolution: After a short propagation period, confirm that
www.annaskopenko.comnow resolves directly to GitHub's servers. You can usedig +short www.annaskopenko.comor an online DNS lookup tool. It should return yourannalogofdesign.github.io.CNAME followed by GitHub's A records (e.g.,185.199.x.153addresses). - Re-trigger Certificate Request: Go to your GitHub repository's Settings → Pages. Remove the custom domain (
annaskopenko.com) and then immediately add it back. This action prompts GitHub Pages to restart the certificate request process with the updated DNS information.
It's important to note that while the new certificate is being issued, https://www.annaskopenko.com might temporarily revert to showing the *.github.io certificate error again. This is expected. The process can take up to an hour for the certificate to be issued and up to 24 hours for 'Enforce HTTPS' to become available. Keeping the www CNAME on 'DNS only' permanently is recommended to avoid future renewal issues, as GitHub Pages handles redirects from www to the apex domain automatically.
Key Takeaways for Robust Pages Deployment
- DNS Proxying Awareness: Be mindful of how DNS proxying services like Cloudflare interact with external services requiring direct DNS validation, especially for certificate issuance.
- 'DNS only' for GitHub Pages CNAMEs: For custom domains on GitHub Pages, ensure CNAME records pointing to
*.github.ioare set to 'DNS only' in Cloudflare to allow GitHub to manage SSL certificates effectively. - Verify DNS Propagation: Always verify your DNS changes with tools like
digornslookupto ensure they've propagated correctly before expecting services to function. - Patience is Key: DNS changes and certificate issuance can take time. Allow for propagation and processing periods.
