Using the 'hosts' file

The hosts file is used to map hostnames to IP addresses. With the hosts file you can change the IP to which you resolve a certain domain name.

This is particularly useful when you wish to see how a website will look when hosted on a different server without having to wait for a DNS change to propagate, or avoiding any DNS changes at all.

The path to the hosts file, depending on the operating system 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

Now let’s say that you wish to resolve your domain to IP In this case the entry you should add to your hosts file would be:

In Windows 7 you might have difficulties editing the hosts file due to the required access level. In order to edit the file navigate to Windows -> Start. Search for Notepad, right-click on the corresponding icon and select Run as Administrator. This should launch notepad with elevated privileges. Next, open the hosts file from the File menu, edit and save it.

For the permission issue, try the following steps:

Take ownership of the hosts file and change the permission for it.

1. Right click on the hosts file and click Properties.
2. Switch to the Security tab and click on the Advanced button.
3. Navigate to the Owner tab and click Edit….
4. Highlight your user account or the Administrators group and click OK twice to quit the Advanced Security Settings dialog box.
5. On the Security tab under the Properties dialog box click Edit….
6. Highlight the Administrators group, check the box for Full control under Allow and click OK.

Please Note : You may need to clear your cache before you can properly resolve the domain to the new IP.