Hosts file allows you to resolve domain names to a specific, often temporary, IP address for testing locally without making a change to public DNS records.
This is often helpful when troubleshooting or testing a new website with a new IP address before launch.
The steps below will guide you on how to change the content of the Hosts file on a Mac.
- Open Terminal
- Type sudo nano /etc/hosts followed by a Return (Nano is a text editor)
sudo nano /etc/hosts
- Type the administrator password for your Mac
- Add the IP address at the end of the file (see sample below 167.234.117.228)
- Press the Tab key
- Enter the domain name that corresponds to the IP address (see sample below of an entry for Businesscloud.ca)
- Ctrl+O to save followed by a Return
- Ctrl+X to exit
- Type killall -HUP mDNSResponder followed by a Return
sudo killall -HUP mDNSResponder
Remember to remove the entry once you are done testing