How to edit your hosts file

Editing your hosts file overrides the DNS entries for any domain by resolving that domain to the IP address of your choice, this change only affects the computer you are making the change on which makes it very useful for testing websites, for example when performing a migration.

Editing your hosts file on Window 8, 8.1 and 10 #

  1. From your start menu locate notepad, right click and select Run as administrator (You may be asked to enter your administrator password at this point)

  1. From Notepad select Select file > open
  2. Navigate to C:\Windows\System32\drivers\etc (this assumes Windows has been installed to the default directory)

  1. To the right of Filename select All Files (*.*)
  2. Open the file named hosts
  3. Create a new line at the bottom and enter the IP address of you new website followed by the domain name, for example:

  1. [alert]Note: Wildcard entries are not supported within the hosts file, in the example above we have included both the non-www and www version of the domain.[/alert]
  2. Select File > save
  3. The change is immediate, now when you enter your domain into your browser it will resolve to your new website allowing you to test your site before going live.

How to disable your host file entries #

If you need to revert back so your domain points at the original IP you can either delete the line you entered and save or you can comment it out by prefixing the line with # which allows you to easily switch between your old and new sites for testing.

As soon as you save the change will take affect.

[alert style=”info”]Using Linux or macOS?
The hosts file and syntax used is standard across almost all operating systems, on Linux or macOS you can find the hosts file here:


Powered by BetterDocs