A local hosts-file entry lets your computer test a website on a chosen server before public DNS changes. Other visitors continue to use the normal DNS records.
Prepare the entry
Back up the hosts file and confirm the destination server has the correct website and certificate configured. Add only the hostnames needed for your test.
Example:
192.0.2.10 example.com www.example.comReplace the documentation address with the actual reachable server IP. Do not include https://, a port or a page path.
Edit on Windows
- Open Notepad with Run as administrator.
- Open
C:\Windows\System32\drivers\etc\hosts, selecting All Files in the file picker. - Add the entry on a new line and save the existing file without a
.txtextension. - If needed, clear the local resolver cache in Command Prompt:
ipconfig /flushdnsEdit on macOS or Linux
Open the file using an administrator account:
sudo nano /etc/hostsAdd the entry and save. In nano, use Ctrl+O, Enter, then Ctrl+X. If a stale local cache affects testing, use the cache-clearing method for your operating system; do not restart unrelated DNS services.
Verify and undo the test
Open the actual domain in the browser, including HTTPS. Check the intended site, not just a generic welcome page. Keep certificate verification enabled.
A proxy, VPN or browser resolution setting may affect the test. Command-line dig usually queries DNS directly and is not a check of hosts-file resolution.
Remove your added entry when testing finishes, then check normal DNS-based access.