Windows Hosts File

Windows Hosts File Location and Basic Usage

When you visit a website, for example Save Location, the domain (in this case, is just an alias for an IP address. If we think about the IP address as the host, and the domain as the name, it's quite clear to see where the name "hostname" comes from: it's the name for a host.

Perhaps the most-commonly used example of a hostname is localhost which is actually just a hostname for But how does your computer know which IP address a hostname points to?

In the case of and localhost, they both use system called DNS (domain name system) which - to really water things down - tells the computer where they point to.

It would also be possible to use the hosts file to declare these. A hosts file defines any and all hostnames that aren't in the domain name system, in fact, one can even override the DNS by changing the hosts file (as it has priority). If you want to learn how to open up the hosts file, read on...

Windows Hosts File Location

The hosts file location on Windows 10, Windows 8, and Windows 7 is the same. You can find it at the following path:


On Windows 8 and 10, you'll need to run the application you wish to open the hosts file with as administrator in order to access it. We'll use Notepad as an example. First, open Notepad as an administrator by right clicking it and selecting Run as Administrator:

Running Notepad as administrator

Then, go to File > Open (or hit CTRL + O):

Notepad Open option

Finally, paste the hosts file location from above into the File name: field and hit Open:

Opening the hosts file path in Notepad

And that's you, inside the hosts file and ready to edit it! If you want to learn how to use the hosts file, read on...

How to Edit the Hosts File on Windows

Each hostname you want to define should be on one line (and there should be a new line for each hostname). The syntax is fairly straight forward, first write the name of the host (e.g. IP address) you want the hostname to point to. Then, after a space (or tab), add the hostname. For example, the below line would make point to

Say you also wanted to add the host to have the hostname, you could just add another line, so the file would look like so: