How to use the hosts file to preview your website

The hosts file is used to map domains to IP addresses. With the hosts file, you can change the IP address that resolves to a domain. This change only affects your own local computer.

This is useful when you wish to see how a website will look like when hosted on a different server without making any DNS changes to your domain. We recommend doing this before changing your primary DNS. This is also necessary for WordPress as they map to the FQDN (Fully Qualified Domain Name).

The location of the hosts file, depending on the operating system that 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


Let's say that you wish to resolve to the IP address In this case you would need to open up the hosts file with a text editor and append the following line:

This will "tell" your computer to resolve to Once you do that you may need to clear your web browser's cache, afterwards, if you try to reach your domain in a browser it should take you to the site hosted on the server with IP

More detailed instructions on how to locate and edit the hosts file on different operating systems are available below:

Windows 8 and 10

  • Press the Windows key (previously Start menu).
  • Use the Search option and search for Notepad.
  • Right-click Notepad and select Run as administrator.
  • From Notepad, open the hosts file at: C:\Windows\System32\Drivers\etc\hosts
  • Add the line and save your changes.


  • Open up the Terminal.
  • Use the nano command line text editor, or a different one you have available to open up the hosts file. The command with nano is as follows (the command will require your Linux user's password):

sudo nano /etc/hosts

  • Add the appropriate changes in the hosts file.
  • Use the Control and X key combination to save the changes

Mac OS X 10.6 through 10.12

  • Open Applications -> Utilities -> Terminal.
  • Edit the hosts file with a command line text editor such as nano by typing the following line in the terminal (the command will require Mac your user's password):

sudo nano /private/etc/hosts

  • Add your changes at the bottom of the file.
  • Save the changes with the Control and X key combination.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Do you block ports?

We have a firewall that block both inbound and outbound ports. If you're running something that...

How do I get SSH Access?

SSH Access is by default disabled for all accounts. It's rare that our clients require this,...

How do I edit the default PHP Timezone for my account?

To edit the default PHP timezone for your account, just edit the .htaccess-file in your...

How do I reach cPanel?

You can either reach cPanel by going to by heading to the control...

Changing the PHP Upload File Size limit

In order to change the file size limit for PHP, follow the below steps:Log into cPanel with the...