How to Restore GitHub Pages Custom Domain After Subscription Lapse
This guide documents how to restore your GitHub Pages site (dapurv5.github.io) with custom domain (vermaapurv.com) if your GitHub Pro subscription expires and your site goes down.
Problem
When GitHub Pro subscription expires:
- The custom domain configuration gets removed from GitHub Pages
- GitHub releases your claim on the custom domain
- Your site shows a 404 error
- You cannot simply re-add the custom domain - GitHub requires re-verification
Prerequisites
- GitHub account with active subscription
- Access to your domain registrar (Squarespace/Google Domains for vermaapurv.com)
- GitHub CLI (
gh) installed and authenticated
Step 1: Verify Domain Ownership with GitHub
1.1 Go to GitHub Account Settings
- Go to https://github.com/settings/pages
- Or: Click your profile picture → Settings → Pages (in left sidebar)
1.2 Add Domain for Verification
- Click “Add a domain”
- Enter your domain:
vermaapurv.com - Click “Add domain”
1.3 Copy the Verification Details
GitHub will show you:
- Hostname:
_github-pages-challenge-dapurv5.vermaapurv.com - TXT Record Value: A code like
145d566669f10cb2303c10d6612a72
Keep this page open - you’ll need to click “Verify” after adding the DNS record.
Step 2: Add DNS TXT Record in Squarespace (formerly Google Domains)
2.1 Access DNS Settings
- Go to https://domains.google.com or https://domains.squarespace.com
- Sign in with your Google account
- Click on vermaapurv.com
- Click DNS in the left sidebar
2.2 Add the TXT Record
- Scroll to “Custom records” section
- Click “ADD RECORD”
- Fill in the fields:
| Field | Value |
|---|---|
| Type | TXT |
| Name | _github-pages-challenge-dapurv5 |
| TTL | 1 hr (default) |
| TEXT | The verification code from GitHub (e.g., 145d566669f10cb2303c10d6612a72) |
- Click “SAVE”
2.3 Verify DNS Propagation
Open Terminal and run:
dig TXT _github-pages-challenge-dapurv5.vermaapurv.com +short
Wait until it returns your verification code (usually 1-5 minutes).
Step 3: Complete GitHub Verification
- Go back to the GitHub verification page (from Step 1.3)
- Click “Verify”
- You should see a green checkmark indicating the domain is verified
Step 4: Add Custom Domain to Repository
Option A: Via GitHub Web UI
- Go to your repository: https://github.com/dapurv5/dapurv5.github.io
- Click Settings → Pages (in left sidebar)
- Under “Custom domain”, enter:
vermaapurv.com - Click “Save”
Option B: Via GitHub CLI
gh api repos/dapurv5/dapurv5.github.io/pages -X PUT -f cname="vermaapurv.com"
Step 5: Wait for HTTPS Certificate
GitHub automatically provisions an HTTPS certificate. This can take 1-15 minutes.
Check certificate status:
gh api repos/dapurv5/dapurv5.github.io/pages --jq '.https_certificate'
Wait until state shows "approved".
Step 6: Enable HTTPS Enforcement
Option A: Via GitHub Web UI
- Go to repository Settings → Pages
- Check the box “Enforce HTTPS”
Option B: Via GitHub CLI
gh api repos/dapurv5/dapurv5.github.io/pages -X PUT -F https_enforced=true
Step 7: Trigger a Site Rebuild (if needed)
If the site still shows 404 after all steps:
gh api repos/dapurv5/dapurv5.github.io/pages/builds -X POST
Check build status:
gh api repos/dapurv5/dapurv5.github.io/pages/builds/latest --jq '.status'
Step 8: Clear Browser Cache
If the site still shows 404 in your browser but works via curl:
- Hard refresh: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
- Clear site data: Chrome DevTools → Application → Storage → Clear site data
- Incognito window: Cmd+Shift+N and visit the site
Verification Commands
Check if site is working:
curl -sI https://vermaapurv.com/ | head -5
Expected output should show HTTP/2 200.
Check GitHub Pages configuration:
gh api repos/dapurv5/dapurv5.github.io/pages
Check current DNS records:
dig A vermaapurv.com +short
dig TXT _github-pages-challenge-dapurv5.vermaapurv.com +short
Current DNS Records (for reference)
Your domain should have these records in Squarespace/Google Domains:
A Records (point to GitHub Pages)
| Type | Name | Data | |——|——|——| | A | @ | 185.199.108.153 | | A | @ | 185.199.109.153 | | A | @ | 185.199.110.153 | | A | @ | 185.199.111.153 |
CNAME Record (www subdomain)
| Type | Name | Data | |——|——|——| | CNAME | www | vermaapurv.com |
TXT Record (GitHub verification - can be removed after verification)
| Type | Name | Data | |——|——|——| | TXT | _github-pages-challenge-dapurv5 | (verification code) |
Troubleshooting
“Custom domain is already taken” error
- You need to verify domain ownership first (Steps 1-3)
- The verification TXT record must be added before GitHub will allow you to claim the domain
Site shows 404 but curl shows 200
- Browser cache issue - do a hard refresh or use incognito
HTTPS not working
- Wait for certificate provisioning (check with
gh api repos/.../pages --jq '.https_certificate') - Make sure “Enforce HTTPS” is enabled
dapurv5.github.io not redirecting properly
- This is expected to redirect to vermaapurv.com when custom domain is set
- Make sure HTTPS enforcement is enabled for proper https:// redirects
File Locations
- CNAME file:
/Users/verapurv/MyCode/dapurv5.github.io/CNAME(containsvermaapurv.com) - This guide:
/Users/verapurv/MyCode/dapurv5.github.io/GITHUB_PAGES_RECOVERY.md
Last updated: April 10, 2026