How to View a Website Not Yet Published in Public DNS (Edit Hosts File on macOS)
Editing the hosts file on macOS allows you to test a website still in development or not yet propagated in public DNS. macOS checks this file before using public DNS servers.
Instructions for macOS (e.g., Snow Leopard and later)
- Open Terminal from
Applications > Utilities - Navigate to the directory containing the
hostsfile:
cd /private/etc/
- Edit the
hostsfile with administrator privileges:
sudo pico hosts
- Enter your Mac user password (no characters will appear while typing).
- Use the arrow keys to scroll to the end of the file.
- Add a new line with the server’s IP and the domain to test. Example:
123.123.123.123 www.testsite.com
- Press CTRL + O, then Enter to save.
- Press CTRL + X to exit the editor.
Note
After saving the file, your Mac will resolve the domain to the specified IP address locally, bypassing public DNS servers. This is useful for testing sites before public launch.