How to edit your host file on Windows

To test how a web server responds to a request with a certain hostname, editing your host file is often the easiest way that doesn’t require you to actually change the domain’s pointer in the dns. This is great for testing a new server without making the change for everyone, or if you are developing something and don’t want to buy a domain yet.

This guide is specifically written for Windows 7, 8 and 10, but the older versions of Windows use almost the same steps.

Start by pressing the Windows key, and typing Notepad in the search field. Right-click the notepad icon and select Run as administrator.

In the top left of Notepad, select File, open, and browse to this path:

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

The layout of the file is pretty simple. For every new line, just start with the IP address you want the host name to point to, add a space and follow it by the host name:

192.168.1.37 www.example.com
192.168.1.37 example.com

Save the file when you’ve added the domains you want. Now all future requests your computer makes to those domains will go to the IP you’ve chosen.

To ignore a line without deleting it, just add a pound-sign before it:

#192.168.1.37 www.example.com
192.168.1.37 example.com

Leave a Reply

Your email address will not be published. Required fields are marked *