The location of the hosts file, depending on the operating system that you are using, is:
- Windows – SystemRoot > system32 > drivers > etc > hosts
By default, the system root is C:Windows, so if you are using Windows, your hosts file is most probably: C:\Windows\System32\drivers\etc\hosts
- Linux – /etc/hosts
- Mac OS X – /private/etc/hosts
So, let’s say that you wish to resolve yourdomain.com to the IP address 188.8.131.52. In this case, you would need to open up the hosts file with a text editor and append the following line:
184.108.40.206 yourdomain.com www.yourdomain.com
This will “tell” your computer to resolve yourdomain.com to 220.127.116.11. Once you do that you will need to clear your web browser’s cache, afterward, if you try to reach your domain in a browser it should take you to the site hosted on the server with IP 18.104.22.168 which is not a live version of your website, rather a snapshot of your staged website.
Instructions on how to access your Hosts File:
Windows 8 and 10
- Press the Windows key (previously Start menu);
- Use the Search option and search for Notepad;
- Right-click Notepad and select Run as administrator;
- From Notepad, open the hosts file at: C:\Windows\System32\drivers\etc\hosts
- Add the line (22.214.171.124 yourdomain.com www.yourdomain.com) at the bottom and save your changes.
In case Notepad does not show any files in the etc folder, switch the type of file from “Text Documents” to “All Files”.
Mac OS X 10.6 through 10.12
You should be logged in with a user with administrator privileges on your MAC.
- Open Applications > Utilities > Terminal;
- Edit the hosts file with a command-line text editor such as nano by typing the following line (sudo nano /private/etc/hosts) in the terminal (the command will require your Mac user’s password):
- Add your changes (126.96.36.199 yourdomain.com www.yourdomain.com) at the bottom of the file;
- Save the changes with the Control and X key combination.