DNS and HTTPS Setup for GitHub Pages: What to Do
A focused look at the DNS records, propagation checks and HTTPS certificate steps behind a custom domain on GitHub Pages, plus fixes for the usual errors.
10 min readUpdated Nov 27, 2026By XPASS Editorial Team

A custom domain on GitHub Pages depends on two layers that are easy to confuse. DNS decides where visitors are sent when they type your name, and HTTPS decides whether the connection they make is encrypted and trusted by the browser. When a site shows a security warning, a 404 page or an old version, the cause almost always lives in one of those two layers, and knowing which one saves hours of guessing.
This article concentrates on the technical side of a Pages setup: which records you need and why, how to inspect them from the command line, how the certificate is issued and renewed, and how to fix the usual failures. If you want the step-by-step flow of choosing a domain and filling in the repository settings, a companion guide covers that, and this one goes deeper into the DNS and HTTPS details behind it. For background on the concepts, the DNS specification itself is the final authority, and an overview of HTTPS explains the encryption side in plain language.
How a visitor reaches your Pages site
Understanding the path makes every later step easier. When someone types www.example.com, their device asks a recursive resolver for the address. The resolver follows the chain: the root servers point to the servers for the top-level domain, which point to the authoritative nameservers for your domain. Those nameservers return the records you configured. For a www name that is a CNAME pointing to username.github.io, and the resolver then looks up that name to receive one or more IP addresses belonging to GitHub.
The browser connects to that address and starts a TLS handshake, announcing which name it wants. GitHub's servers read the name, find the Pages site that claims it, and present a certificate for that name. If the certificate matches and is trusted, the padlock appears and the page is served.
Two consequences follow. First, DNS only gets the visitor to GitHub; the Pages settings decide what GitHub shows. Second, the certificate belongs to a name, so a name that is missing from the settings cannot get one, no matter how perfect your DNS looks.

The DNS records you need
| Goal | Name | Type | Value |
|---|---|---|---|
| Serve the apex domain | @ (example.com) | A | 185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153 |
| Serve the apex over IPv6 (optional) | @ | AAAA | GitHub's published IPv6 addresses for Pages |
| Serve www | www | CNAME | username.github.io |
| Verify domain ownership (optional) | name shown by GitHub | TXT | value shown by GitHub |
Check the current list in GitHub's own documentation before you copy anything, since addresses can change. The principle is stable, though: an apex uses address records, a subdomain uses an alias record, and each name has a clear owner.
A few rules keep the zone clean:
- A name with a CNAME must not have any other record type. That is a core rule of DNS, and it is why the apex, which must hold SOA, NS and often MX records, cannot be a CNAME at most providers.
- Do not mix GitHub addresses with other addresses for the same name. Resolvers rotate answers, so half of your visitors would land elsewhere.
- Keep a TTL that you can live with. A value of 3600 seconds (one hour) is reasonable; lower it before a planned change so mistakes correct themselves faster.
- Leave MX, SPF, DKIM and DMARC records alone. They are unrelated to the website.
If you have not registered the name yet, the domains page lists what is available.
Check your records from the command line
Do not rely only on the green tick in the dashboard. The command line shows what the world actually sees. On macOS and Linux, dig is the usual tool; on Windows, nslookup does the same job.
- Query the apex: run dig example.com A +short. You should see exactly the four GitHub addresses and nothing else.
- Query IPv6 if you set it: dig example.com AAAA +short.
- Query www: dig www.example.com CNAME +short. The answer should be username.github.io followed by a dot.
- Query a public resolver directly to bypass your local cache, for example dig @1.1.1.1 example.com A +short, and compare with another such as 8.8.8.8.
- Check for CAA restrictions: dig example.com CAA +short. No answer means no restriction; any answer should allow the certificate authority GitHub uses.
If different resolvers return different answers, propagation is still in progress. The old record is cached until its TTL expires. If every resolver returns the same wrong answer, the fault is in your zone, not in the cache.
How the HTTPS certificate is issued
GitHub uses an automated process based on the ACME protocol described in RFC 8555. In simple terms, GitHub asks a certificate authority for a certificate for your name. The authority sends a challenge that can only be answered by whoever controls that name's DNS and web serving. Once GitHub answers it, the authority signs a certificate, which is then installed for your domain. The whole thing is automatic and typically completes within an hour of GitHub detecting correct DNS.
This explains the order of events. If your DNS still points elsewhere, the challenge fails. If you add the custom domain before the DNS exists, GitHub cannot complete it. And if a CAA record forbids the authority, the signing step is refused. In every case the fix is to correct the cause and let GitHub retry, which it does periodically. Removing and re-adding the custom domain in the repository settings forces a fresh attempt.
Renewal works the same way. GitHub renews before expiry without any action from you, provided the DNS keeps pointing to Pages. This is why leaving a domain's records in place matters: if you later move the DNS to a different host, the renewal check will stop working for the old setup.
Enforce HTTPS and fix redirects
When the certificate is ready, tick Enforce HTTPS in Settings, Pages. GitHub then redirects every plain HTTP request to the HTTPS version. Test both forms in a private window.
Several details are worth checking once HTTPS works:
- Pick one canonical address. If your custom domain is www.example.com, the apex should redirect there with a permanent redirect, which GitHub does for you when both names are configured. If you see two versions of the site both returning a normal page, one of the records is wrong.
- Make sure links inside your pages use relative paths or HTTPS. A single image loaded over plain HTTP creates mixed content, and browsers will block or flag it, removing the padlock even though the certificate is fine.
- Update your sitemap, canonical tags and social preview links to the final HTTPS address. Search engines use these to decide which version to index.
- Think carefully before adding strict transport security headers. A site served from GitHub Pages cannot set custom response headers, so if you need that level of control, consider a different layer in front of the site.
For a deeper look at certificates that you manage yourself, such as for a server or an API, see the SSL certificates page.
A worked example: tracing a failure
Suppose visitors to www.example.net report a certificate warning, but example.net without the prefix works.
- You run dig www.example.net CNAME +short and get nothing. That means the CNAME record was never created or was saved under the wrong name.
- You open the DNS dashboard and find a record named www.example.net.example.net. Some providers append the domain automatically, so typing the full name created a doubled name.
- You delete it and create a CNAME with the name set to just www and the value set to myname.github.io.
- After a few minutes, dig now returns the alias. In the repository settings you remove the custom domain, save, then add www.example.net again.
- Within the hour the certificate is issued, Enforce HTTPS becomes clickable, and the warning disappears.
The lesson is that the dashboard showed a record, but the command line showed what resolvers actually saw. Reading the real answer is the quickest way to find a typing mistake.
Keep a short log of every change you make, with the date, the record and the old value. When something breaks a week later, that log tells you what changed, and it turns a stressful investigation into a quick comparison. It also helps a colleague who inherits the site understand why each record exists.

Limits and what to watch for
- Pages cannot set custom HTTP headers or run server code, so headers such as a content security policy, or redirects based on the visitor, need a separate service in front.
- Certificates are issued for the names configured on the site. Adding a new subdomain later means adding it to the Pages configuration rather than just creating a DNS record.
- Dangling records are a risk. If you delete the repository or remove the custom domain but leave DNS pointing at GitHub, someone else may be able to claim the name. Remove the records when you stop using Pages, and verify the domain in your account settings if you want an extra safeguard.
- CDNs and proxying layers placed in front of Pages can interfere with certificate issuance. If you use one, pause the proxy while the certificate is issued, or follow GitHub's guidance for that setup.
- Do not copy IP addresses from forum posts or old tutorials. Use the current official list.
- Changing nameservers moves your entire zone. Recreate every record, especially email, before you switch.
Troubleshooting checklist
| Symptom | First thing to check |
|---|---|
| Browser says the connection is not private | Is the certificate issued? Is the custom domain set in Pages? |
| Enforce HTTPS greyed out | dig the apex and www; look for stale A, AAAA or CAA records |
| Page loads but padlock has a warning | Search your pages for http links to images, scripts or fonts |
| Works on your phone, not on your laptop | Local DNS cache; flush it or test with a public resolver |
| 404 from GitHub | The repository has no published content or the domain is not set in Pages |
| Email broke after the change | Compare the zone with your saved copy and restore MX and TXT records |
Each of these has a single most likely cause, and checking in the order of the table usually finds it within minutes. Working through the same sequence on other platforms is covered in the related guides for Notion Sites, Ghost and Astro, which are useful for comparing how different hosts handle certificates.
Summary
For GitHub Pages, DNS gets visitors to GitHub and the Pages settings tell GitHub which site to show. Use A records for the apex and a CNAME for www, keep email records intact, and confirm the real answers with dig instead of trusting a dashboard. The HTTPS certificate is issued automatically once the name is configured and DNS is correct, and it renews on its own while the setup stays in place. Fix mixed content, pick one canonical address, and remove stale records when you retire the site. When you are ready to choose or manage a name, the domains page is a good next step.
Frequently asked questions
Which DNS records does a GitHub Pages custom domain need?
An apex domain needs A records (and optionally AAAA) pointing at GitHub's published Pages addresses. A www or other subdomain needs one CNAME pointing at your github.io address. Email records stay as they are.
How can I check that my DNS records are correct?
Use a command such as dig or nslookup, or an online lookup tool, to see which addresses the name returns, and compare them with the list in the GitHub documentation. Test from more than one network.
Why is my HTTPS certificate not being issued?
The most common causes are DNS records that are still propagating, leftover records pointing at another host, or a CAA record that does not allow the certificate authority GitHub uses.
Do I need to renew the HTTPS certificate myself?
No. GitHub renews the certificate automatically as long as your DNS keeps pointing at GitHub Pages and the custom domain stays set.
What is mixed content and why does it break the padlock?
Mixed content is a secure page that loads images, scripts or styles over plain HTTP. Browsers block or warn about these resources, so change the links in your pages to HTTPS or to relative paths.
References
About the author

Bob Kanokphon Thongdee
- Founder of XPASS VPN
- Co-founder of eSIMonline.asia
- More than 7 years in online marketing
- Founder of Cojourney Visa and Cojourney Travel
Ready to register your domain?
Search a name, compare extensions and pay once for the years you choose.
.com registration from $18.81 for the first year
Search domainsKeep reading

Domain & DNS Guides
DNS and HTTPS Setup for Notion Sites: A Practical Guide
What DNS records a Notion Sites custom domain needs, how HTTPS is handled for you, and how to fix verification, redirect and certificate problems.
9 min read

Domain & DNS Guides
DNS and HTTPS Setup for Ghost: What You Need to Do
A focused guide to the DNS records and HTTPS settings a Ghost site needs: record types, TTL, certificates, redirects and how to troubleshoot warnings.
10 min read

Domain & DNS Guides
How to Set Up DNS and HTTPS for an Astro Site
A practical guide to DNS records, certificates, redirects and HSTS for an Astro site, with the project settings and checks that keep pages and links secure.
10 min read