Previewing Your New Website – Modifying Your Hosts File

In order to see your new website prior to making it live, you need to modify a special file (the “hosts file”) on your computer which will let you see your new website on our server, rather than the one that it is currently on.

Once you confirm your site is good to go, we will redirect your web domain (eg. your company.ca) so the it sees the site on our server.

How To Edit Your Hosts File

Thank you to our server hosting firm LiquidWeb for these directions.

The location of your computer’s hosts file depends on your operating system. Because it is a protected file which must be edited with administrative privileges, the procedure for editing also varies by operating system.  If you experience difficulties editing your hosts file or are not seeing the sites on the new server after you’ve followed the steps below, contact us.

Windows

In Windows, the hosts file is located at: C:\Windows\System32\drivers\etc\hosts. You will need to edit the file with administrative privileges.

  1. Click Windows button and type ‘Notepad’ in the search
  2. Right click on ‘Notepad’ and then ‘Run as Administrator’
  3. Choose ‘Yes’ on the User Account Control popup
  4. In Notepad, choose ‘File’ then ‘Open’
  5. Click the address bar at the top and paste C:\Windows\System32\drivers\etc\hosts – choose ‘Enter’
  6. Choose Notepad from the list and then OK
  7. Add the appropriate IP and hostname (give by us) at the end of your hosts’ file, select save and close the file
  8. Finally, you will want to flush your DNS cache so you don’t have to log out and back in for the changes to take effect:
    Open an elevated command prompt as above, and enter the following command:
    ipconfig /flushdns

Mac OS X

On Mac OS X, your hosts file is located at: /private/etc/hosts. You will need administrative privileges to edit the file, which you can do manually or by appending the new entry directly from the command line.

  1. First, launch Terminal from Spotlight search (Command+Space, or click on the magnifying glass icon in your menu bar) or the Utilities folder in Applications on many versions of Mac OS X.
    • To edit the file manually:
      1. Enter the following command in Terminal:sudo nano /private/etc/hosts
      2. Enter your password when prompted and press Enter to authenticate and open the file.
      3. Now add the appropriate line and save the file:
        1. Use your arrow keys to navigate to the bottom of the file.
        2. Type in (or paste) the IP address and website name you intend to redirect.
        3. Press Control+O to save (Write Out) the file.
        4. Press Enter to overwrite the existing file.
        5. Finally, press Control+X to exit.
    • If you prefer to simply append the entry to the existing file, you can do so with one command, substituting your server’s IP address and domain name for the ones in this example:echo "1.1.1.1 test.com www.test.com" | sudo tee -a /private/etc/hosts >/dev/nulland enter your password when prompted.
  2. While you still are in Terminal, you should flush the DNS cache so you don’t have to log out and then log back in for the changes to take effect. For the current version of Mac OS X, you can do that with this command:dscacheutil -flushcache; sudo killall -HUP mDNSResponder

    Note: On the first few releases of Mac OS X Yosemite (versions 10.10 through 10.10.3), the command needed to flush the cache is sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches. For version-specific instructions in older versions of Mac OS X, see How To Flush Your Local DNS cache.