How to Edit Host File

July 20, 2022 / How-to Guide

A host file is a simple, plain-text file which contains a list of host names and their corresponding IP addresses.

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, during a migration.

Where Is the Hosts File Located on Windows?

c:\Windows\System32\Drivers\etc\hosts

How to Edit the Hosts File on Windows (8, 8.1, 10, 11)?

  1. Open the Start Menu and search for Notepad.
  2. Right-click Notepad and select Run as administrator.
    notepad
  3. In Notepad, click File > Open.
  4. Navigate to the following location:
    C:\Windows\System32\Drivers\etc
  5. Change File type to All Files (.).
  6. Select the file named hosts and click Open.
  7. Add a new line at the bottom of the file and enter the IP address followed by your domain name, for example:
    203.0.113.10 mywebsite.co.uk www.mywebsite.co.uk
    Note: 203.0.113.10 is a sample IP address used for documentation purposes. Replace it with your server’s actual public IP address.
  8. Click File > Save.

The change will take effect immediately. When you enter your domain in a browser, it will resolve to the specified IP address, allowing you to test your website before it goes live.

Notes and Best Practices:

  • Wildcard entries are not supported in the hosts file.
  • Include both www and non-www versions of the domain if required.

  • Always verify that you are using the correct public IP address of your server.

How to Disable or Remove Hosts File Entries?
If you want to revert your domain to its original DNS configuration, you can use one of the following options:

Option 1: Delete the Entry
Remove the line you added and save the file.

Option 2: Comment Out the Entry
Add a # at the beginning of the line to disable it temporarily:

#203.0.113.10 mywebsite.co.uk www.mywebsite.co.uk

Saving the file will apply the changes immediately.

This is how you can edit the hosts file on a Windows system. If you have any questions or need further assistance, please contact our support team.

Spread the love