How do I modify the host file?

Modifying your hosts file will allow you to override the DNS for a domain, on that the particular machine can be used to test your site without the test link, verify an alias site works prior to DNS changes, or for other DNS related reasons. This causes your local machine only to look directly at the IP specified on the host file.

Your hosts file will need to have two entries added that will contain the IP address you want the site to resolve to and the address. Adding the below two lines for example will point www.domain.com and domain.com.

 

123.123.123 123  domain.name
123.123.123.123. www.domain.name
 

For Windows OS

For Windows OS and Notepad must be run as Administrator.

1. Click Start -> All Programs -> Accessories.

2. Right click Notepad and select Run as administrator.

3. Click Continue on the "Windows needs your permission" UAC window.

4. When Notepad opens Click File -> Open.

5. In the file name field type:

C:\Windows\System32\Drivers\etc\hosts

6. Click Open.

7. Make the necessary changes to the hosts file.

8. Click File -> Save to save your changes.

 

For Latest Mac OS

1. Open Applications > Utilities > Terminal.

2. Open the hosts file by typing the following in the Terminal window:

   sudo nano /private/etc/hosts

Type your user password when prompted.

3. Edit the hosts file. The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (e.g. 127.0.0.1 – local host). Append your new mappings underneath the default mappings.

4. Save the hosts file by pressing Control+x and answering  Y.

5. Make your changes take effect by flushing the DNS cache with the following command:

   dscacheutil -flushcache

6. New mappings should now take effect.

Add Feedback