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)
    run_notepad

    Opening Notepad

  2. From Notepad select Select file > open
  3. Navigate to C:\Windows\System32\drivers\etc (this assumes Windows has been installed to the default directory)
  4. To the right of Filename select All Files (*.*)
  5. Open the file named hosts
    Opening the hosts file

    Opening the hosts file

  6. Create a new line at the bottom and enter the IP address of you new website followed by the domain name, for example:
    192.168.0.10 myeukwebsite.co.uk www.myeukwebsite.co.uk

    hosts_file

    Editing the hosts file

    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.
  7. Select File > save
  8. 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.

hosts_file_comment

This entry has been disabled by adding a #

As soon as you save the change will take affect.

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:
/etc/hosts