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.


The IP-address of your Zone virtual server can be found in the webhosting management under Webhosting and System information

For example: example.com 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!


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\

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

Mac OS

  • Open the Mac Terminal. Open the Finder, and go to Applications > Utilities > Terminal.

  • Type sudo nano /private/etc/hosts in the terminal window, enter user password and hit Enter.


  • In the host file, first enter the IP address and then the domain name.
    For example: example.com www.example.com


  • Save your changes by pressing Command + O, then exit by pressing Command + X.
  • In Terminal, type sudo killall -HUP mDNSResponder to clear your Mac’s DNS cache. This will prevent any clashes between DNS and the Hosts file.

In order to undo the changes, repeat the process above and simply delete the previously added rows.

Updated on 16. May 2024

Was this article helpful?

Related Articles