Invalid DNS Error on GitHub Pages: Causes and Fixes
In this article
An "invalid DNS" error on GitHub Pages almost always means your custom domain's DNS records are missing, wrong, or not yet propagated. Check the DNS entries at your registrar first, then confirm GitHub Pages is enforcing HTTPS before the domain will serve.
Time 30 min · Steps 6 · Level Medium
Fix an Invalid DNS Error in Six Steps
- Open your DNS control panel. Log in to your domain registrar (where you bought the domain, such as the company you used for the purchase) and find the DNS or nameserver settings for the domain.
- Point the apex domain at GitHub Pages. Add A records pointing to GitHub's Pages servers: 185.199.108.153, 185.199.109.153, 185.199.110.153 and 185.199.111.153. Some registrars do not allow A records on the apex; in that case use the ALIAS or ANAME record type if offered, pointing to username.github.io.
- Point any subdomain with a CNAME record. For www or other subdomains, add a CNAME record whose value is your GitHub Pages host, in the form username.github.io (or orgname.github.io for an organisation).
- Set the custom domain in GitHub Pages. In your repository, go to Settings > Pages, type the domain in the Custom domain field and save. This writes a CNAME file into your branch, so do not delete that file later.
- Wait for DNS propagation. Changes can take from a few minutes up to about 24 hours to spread, and up to 48 hours in rare cases. Nothing you do on GitHub speeds this up; re-check after an hour before assuming the records are wrong.
- Enable HTTPS. Once DNS resolves, tick Enforce HTTPS under Settings > Pages. This option stays greyed out and shows a DNS error until the records are correct and propagated, so a greyed-out button is itself a useful diagnostic.
Tell a Record Problem From a Propagation Problem
The single symptom that splits the causes: whether the domain fails immediately with a DNS error everywhere, or works in some places and tools but not in your browser. A record that is wrong or missing fails everywhere and instantly. Propagation fails unevenly, and often clears on its own within hours.
To confirm which one you have, run a lookup from outside your own browser. On Windows, open Command Prompt and type nslookup yourdomain.com; on macOS or Linux, use dig yourdomain.com in Terminal. If the answer shows the four GitHub Pages addresses above, your records are right and you only need to wait. If it shows something else, or no answer, the records are the problem. An online DNS lookup tool gives you a second opinion from a different network, which helps when your own machine has cached an old answer.
Browser and operating system caches also hold onto DNS answers. A hard refresh may not be enough because the cached record sits below the browser. Clearing the browser cache, or flushing the OS DNS cache (ipconfig /flushdns on Windows), rules this out before you start editing records.
Records That Look Right but Still Fail
Conflicting records
A CNAME record cannot coexist with other records on the same name at some providers. If www fails while the apex works, check whether an old A record or a parking record from the registrar sits alongside your CNAME and delete it. Confirm by looking at the full record list for that hostname in the DNS panel, not just the CNAME row.
Wrong record value
A CNAME must point to username.github.io exactly, with no https://, no trailing path and no typo. Extra characters are the most common single cause of a persistent invalid DNS error. Confirm by comparing the record value character by character against your repository's Pages URL.
Nameservers not at the registrar you are editing
If the domain's nameservers point elsewhere (for example to a separate DNS provider or a hosting company), the records you add at the registrar are never read. Confirm in the registrar's nameserver settings; the fix is either to change the records at whichever service the nameservers point to, or to switch the nameservers back to the registrar's defaults and wait for that change to propagate.
The domain itself has lapsed
An expired domain stops resolving entirely. Check the expiry date in your registrar account before spending time on records; the fix is renewing it, then waiting for DNS to come back, which can take a few hours.
Repository settings
If DNS looks correct but GitHub still complains, confirm the custom domain in Settings > Pages matches the domain exactly, including www or its absence, and that the CNAME file in your branch contains that same single line. A mismatch between the two produces errors that look like DNS faults. Menu labels can differ slightly between GitHub versions.
Prevention and a Pre-Launch Checklist
Once the site works, two habits prevent nearly every repeat of this error. First, keep the DNS records untouched after they are verified, and note the registrar account they live in, since a forgotten account is where domains go to break. Second, keep the CNAME file in your repository and add it to git rather than letting a build script or deploy process overwrite or delete it.
Before announcing a site on a custom domain, run this short checklist:
- nslookup or dig returns the four GitHub Pages IP addresses for the apex domain.
- The www CNAME resolves to username.github.io (if you use www).
- The custom domain field under Settings > Pages matches the URL you will share, character for character.
- Enforce HTTPS is ticked and no longer greyed out.
- The site loads in a private browsing window, which bypasses cached DNS and cached redirects.
If everything passes and the site still shows an invalid DNS error after 48 hours, the fastest next step is to remove the custom domain from Settings > Pages, save, re-enter it and save again. That asks GitHub to re-check the DNS from scratch and clears stuck verification state on their side more often than anything else you can do from your own accounts.
Official source: GitHub Docs