A host file entry consists of a domain name and an IP address of the hosting server. When you access the domain name, your browser will redirect you to that hosting server which could be different from the actual live website. This is necessary if you test a staging site, given that it is hosted on a different server.
Add a host file entry if there is none for your domain name or website. Follow the steps below to add the entry. Edit a host file entry if you want to change the IP address for the same domain name or website. You need to do the same thing to disable it so that you can access the actual live website.
- Open Finder.
- Select Go.
- Click Utilities.
4. Open the Terminal application.
5. Type sudo nano /etc/hosts and press Return.
6. Enter your admin password (your password to log in to your device).
7. Use the Return key to create some space below the existing records
8. Enter the TCP/IP address.
9. Press the Tab key.
10. Type in the domain name.
11. Save the file by pressing Ctrl + O.
12. Close the window by pressing the keys Ctrl + X.
13. Type sudo killall -HUP mDNSResponder followed by Return to clear your device’s DNS cache.