A hosts-file entry maps a hostname to an IP address on your own computer. It is useful for testing a website on a chosen server before changing public DNS.

Prepare the mapping

Back up the file first. Use a new line in this form:

192.0.2.10 example.com www.example.com

Replace the example address and hostnames with the intended values. Preserve existing system entries. A hosts file uses names and addresses, not full URLs.

Edit on Windows

Open Notepad with Run as administrator, then open C:\Windows\System32\drivers\etc\hosts. Choose All Files if the file picker hides it.

Add the entry and save it without a .txt extension. If the local resolver cache needs clearing, run ipconfig /flushdns in Command Prompt.

Edit on Ubuntu or macOS

Open a terminal and run:

sudo nano /etc/hosts

Add the entry, then save with Ctrl+O, Enter and exit with Ctrl+X. Use the platform’s supported cache-clearing method only if stale local answers affect the test.

Test and remove the entry

Open the hostname in your browser and check the intended server’s site and HTTPS certificate. Proxies or browser DNS settings may affect how the name is resolved.

Remove the test line afterwards and confirm normal access. This mapping does not change DNS for other users and is not a complete website-blocking system. 0.0.0.0 is not the same as the loopback address 127.0.0.1.