Editing the HOSTs File

Modifying your hosts file will allow you to override the DNS for a domain, on that particular machine. This can be used to test your site without the test link, prior to going live with SSL, 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.

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. 

127.0.0.1 domain.com www.domain.com
 

Below is how to locate and edit the hosts file on several OS platforms. Once the proper domain information is added you will save the file and your system will begin resolving to the specified IP. Once testing is finished these entries should be removed.

 

Windows 8

Notepad in Windows 8 must be run as Administrator.
  1. Search for Notepad in the Windows 8 Metro interface.
  2. Right click on Notepad in the search results list and click Run as administrator.

 

Windows Vista and Windows 7

Vista and Windows 7 use User Account Control (UAC) so 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 filename field type C:\Windows\System32\Drivers\etc\hosts
  6. Click Open

 

Windows NT/2000/XP

  1. Click Start -> All Programs -> Accessories -> Notepad
  2. Click File -> Open
  3. In the filename field type C:\Windows\System32\Drivers\etc\hosts
  4. Click Open

 

Linux

  1. Open a terminal window
  2. Type sudo nano /etc/hosts (you can substitute any text editor)
  3. Enter your password