Run Localhost with Custom Domain in Chrome
22 Jul 2025🛠️ Goal
Run your local website on localhost but access it via a custom domain (e.g. example.ai) without editing /etc/hosts.
🔧 Steps
1️⃣ Install ModHeader Chrome extension
👉 ModHeader on Chrome Web Store
2️⃣ Create a new profile in ModHeader
- Set Request headers:
- Header:
Host - Value:
example.ai
- Header:
3️⃣ Set URL filter to match your localhost IP
Example:
*://127.1.22.33/*
4️⃣ Open http://127.1.22.33 in Chrome
Chrome will send requests with Host: example.ai so your backend sees the expected domain.
✅ Benefits:
- No need to modify system files like
/etc/hosts. - Works instantly per-browser.
- Supports testing multiple domains locally.
Quick summary:
- Install ModHeader
- Add
Host: yourdomain.comheader - Filter requests to your local IP
- Test like it’s a real domain