• Portal Home
  • Knowledgebase
  • Transfers and migrations
  • How to Preview your Website on your WHC Account using the Hosts File

How to Preview your Website on your WHC Account using the Hosts File

During website migrations or before important deployments, it may be useful to preview your site on the new server before you've updated your domain's DNS in order to identify and troubleshoot potential bugs.

This article will show you a technique to test your website securely and completely by modifying a configuration file on your computer called the hosts file.

Hosts file format

The hosts file contains multiple lines. Each line will contain an IP address, followed by one (or multiple) spaces, follwed by a domain name. For example:
203.125.35.128 yourdomain.com
To correctly configure your hosts file. We recommend adding (or modifying, if you have already added them) 2 lines at the end of the file, one for your domain with and without the www, as follows:

203.125.35.128 yourdomain.com
203.125.35.128 www.yourdomain.com

  • Replace 203.125.35.128 with the actual IP address of your website. This can vary depending on your service. Please contact Web Hosting Canada's support team and ask if you do not know your IP address.
  • Replace yourdomain.com by your actual domain name.

How you edit your hosts file will vary depending on which operating system you are using on your computer:

For Windows 8, 10 or 11 

  1. Click on the Windows key
  2. Enter Notepad in the search field
  3. In the search results, right-click on Notepad and select Run as Administrator
  4. In Notepad, open the file: C:\Windows\System32\Drivers\etc\hosts
  5. Make your changes as described above and save your file.
  6. Restart your browser and, optionally, empty its temporary files.

For Windows 7 or Vista 

(also works on most older Windows versions as well)

  1. Click on the Windows key or Start button
  2. Click All Programs > Applications
  3. Right-click on Notepad and select Run as Administrator
  4. Click Continue to execute Notepad as an administrator
  5. In Notepad, open the file: C:\Windows\System32\Drivers\etc\hosts
  6. Make your changes as described above and save your file.
  7. Restart your browser and, optionally, empty its temporary files

For Linux

  1. Modify and save your changes with your preferred text editor (vi or nano). The file is called: /etc/hosts

For Mac

  1. Open the Terminal application
  2. Run the command: sudo nano /private/etc/hosts
  3. If prompted, enter your administrative password
  4. Modify the file as described above save your changes (Control + x, then y to confirm)
  5. Now flush your Mac's DNS cache with: dscacheutil -flushcache

You're done!



Article ID: #HC6000

Was this answer helpful?