The hosts file is a text-based file located in the same identify in all modern Windows versions. Most people don't ever need to get into it, but if y'all do, y'all'll need to know how to open and edit the hosts file.

However, in some versions of Windows, editing the hosts file directly isn't allowed. In fact, you'll get an error if y'all try to save the changes. Fortunately, there'south a unproblematic tip you can use to edit the hosts file in Windows ten, 8, 7, Vista, or XP.

What Does The Hosts File Do?

The purpose of the hosts file was originally to be what DNS servers do now – map friendly domain names to unfriendly IP addresses.

It'southward much easier to remember a domain name like YouTube.com than an IP address like 172.217.1.238. Instead of having to type the IP address into the address bar each fourth dimension you want to watch YouTube videos, you tin merely enter the domain proper noun, and the DNS server your device is using will map the name to the right address then y'all tin get to the webpage a lot easier.

The hosts file, since it serves as a sort of DNS server, works the same fashion. You can enter an IP address that a domain name should be resolved to. In other words, you lot could order your computer to load a different IP address than the DNS server would, substantially letting yous exercise a few absurd things.

Why Edit The Hosts File?

One reason to edit the hosts file is if you desire a super basic way to block websites from loading on your computer. Enter an invalid or incorrect IP address for the site you want to block, and each time you try accessing it, the hosts file will load the IP address you chose. Depending on what you lot picked, it might completely block the website.

Y'all can use the same technique to make the hosts file block malicious sites. There are fifty-fifty lists of hosts file entries (such as this one) you can download and import into your hosts file to block hundreds of malicious sites or ads.

Another use for the hosts file is to speed up your spider web browsing. If the DNS server you're using is down or non working quickly enough, manually entering the IP address and domain name mappings in your hosts file lets your computer discover those addresses nearly instantly instead of relying on the DNS server.

Tip: Learn how to use alternate DNS servers to get faster internet access.

Windows Hosts File Location

Yous need to know where to go to find the hosts file before you can open it for editing. This is the hosts file location in Windows 10 through Windows XP:

C:\Windows\system32\drivers\etc

How To Edit The Hosts File

The hosts file is a text file, pregnant that you need a text editor to make changes to it. However, since the hosts file is super basic and doesn't need to bargain with hyperlinks, images, etc., yous can use a basic text editor (i.e., in that location's no need to employ a full-fledged editor like Microsoft Give-and-take).

Opening The Hosts File

Allow'south start with simply opening the hosts file. We'll apply Notepad, which is congenital into Windows 10 downwards through Windows XP.

  • Open up the Run dialog box by property down the Windows key and and so pressing R once.
  • Type notepad so printing Enter to open the plan.
  • Go to File > Open.
  • In the file name text box at the bottom, blazon (or copy and paste) the hosts file location shown above and then press Enter.
  • Select the menu to the right of the text box to change Text Documents (*.txt) to All Files (*).
  • Double-click hosts from the list of files to open the hosts file for editing in Notepad.

Editing The Hosts File

At that place are a few examples in the hosts file to bear witness you lot how to format your entries. You have to put the IP address first followed by the domain name, and the two have to exist separated past at to the lowest degree ane space (a tab is a good way to format them).

Here are some examples:

127.0.0.1      world wide web.google.com
13.249.79.104  www.bing.com

As you tin see in the epitome above and read from the directions in the hosts file, the # symbol is used every bit a comment, meaning that anything that follows it is avoided. This is why the two example lines nosotros requite above are useful in this hosts file; they're not being followed by that symbol.

Related: Edit Hosts File to Add Local DNS Lookup

If you want to block websites with the hosts file, such as YouTube, Amazon, Google, Reddit.com, etc., you can enter a faux IP accost like 0.0.0.0.

Notation: When you enter the URL of the site you desire to associate with a specific IP accost, be certain to exclude the start part and only type the subdomain, such equally www or whatsoever information technology happens to be for the site you're adding.

Saving The Hosts File

Hither'south how we'll salve the hosts file to make sure information technology works no matter which operating system you utilise, which text editor you picked, or how your Windows settings are configured:

  • Go to File > Save Every bit.
  • Change the Save as type option to All Files (*).
  • Rename the file to hosts.backupfile, and then save information technology to your desktop.
  • Shut Notepad and so find the hosts file you only created on the desktop. You desire to delete the .backupfile part of the proper noun and leave but hosts (with no menses or text later the word).
  • After you lot do that, click away from the file to something else on the desktop, and confirm the proper name change when asked.
  • Copy the hosts file.
  • Open the hosts file location you had open before (the etc folder).
  • Paste the hosts file you copied from the desktop, and confirm any overwrite prompts if you run into them.