1. Home
  2. Technical
  3. How to edit the hosts file

How to edit the hosts file

Sometimes there are situation, when you need to view a website before redirecting a domain to it first. For example, when migrating your website onto a virtual server at Zone and wishing to ensure the website works as it should before connecting your domain to it, or when you’re developing a new website on another server.

One way is to change the hosts file on your computer.

Hosts file allows you to specify the exact IP address of the server from which your local computer is requesting information about a particular website.

Hosts file editing example

For example, you have a website example.com that you’re migrating to a server at Zone.

To ensure that the website works before redirection DNS records, you must specify the IP address of the new server and the domain name in hosts file.

Attention!

The IP-address of your virtual server in Zone can be found in the web hosting management panel under “System information”

For example:

38.25.63.10 example.com
38.25.63.10 www.example.com

After saving the file, open your web browser and refresh the page. The website should then open from the IP-address you specified in the hosts file. We recommend opening the website in incognito mode to avoid the browser’s cache intervening the site’s loading cycle.

These changes only affect the way your website is shown locally on your computer not on the world wide web!

To undo the changes either comment out the lines out by adding a  # symbol in front of them or by completely deleting the added text!

Attention!

Don’t forget to remove your domain names from the hosts file. Otherwise it might cause confusion later or when for example the IP-address of the server changes.

Where to find the hosts file?

Windows 10 and 8

  • Press the Windows key on your keyboard, to open the “Start” menu and type ‘notepad‘ into the search bar
  • Right click on the notepad icon and choose “Run as administrator
  • After opening Notepad choose “File” -> “Open..” and paste the location of your hosts file , which by default is: c:\Windows\System32\Drivers\etc\
    Attention!

    Make sure all file types are displayed: All Files (*.*) !

 

Updated on 28. Jan 2021

Was this article helpful?

Related Articles