The hosts file is a text-based file located in the same place in all modern Windows versions. Most people don't e'er need to get into information technology, simply if y'all do, y'all'll demand to know how to open and edit the hosts file.

However, in some versions of Windows, editing the hosts file directly isn't immune. In fact, you'll get an error if you effort to save the changes. Fortunately, there's a simple tip you tin can use to edit the hosts file in Windows 10, 8, vii, Vista, or XP.

What Does The Hosts File Do?

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

It'south much easier to remember a domain proper name like YouTube.com than an IP accost 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 can just enter the domain name, and the DNS server your device is using volition map the name to the right address so yous can get to the webpage a lot easier.

The hosts file, since information technology serves as a sort of DNS server, works the same way. You tin enter an IP address that a domain name should exist resolved to. In other words, you could order your reckoner to load a different IP address than the DNS server would, essentially letting y'all do a few cool things.

Why Edit The Hosts File?

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

You tin use the same technique to make the hosts file block malicious sites. There are even lists of hosts file entries (such as this i) you can download and import into your hosts file to block hundreds of malicious sites or ads.

Some other use for the hosts file is to speed up your web browsing. If the DNS server you're using is down or not working apace plenty, manually inbound the IP address and domain proper noun mappings in your hosts file lets your computer notice those addresses nearly instantly instead of relying on the DNS server.

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

Windows Hosts File Location

You need to know where to go to find the hosts file earlier 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, meaning that you demand a text editor to make changes to it. Nevertheless, since the hosts file is super basic and doesn't need to bargain with hyperlinks, images, etc., you can use a bones text editor (i.east., there'due south no need to apply a full-fledged editor like Microsoft Word).

Opening The Hosts File

Let'southward starting time with simply opening the hosts file. We'll use Notepad, which is built into Windows 10 down through Windows XP.

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

Editing The Hosts File

At that place are a few examples in the hosts file to show you how to format your entries. Y'all have to put the IP address first followed by the domain proper noun, and the two have to exist separated by at to the lowest degree i 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 y'all can run into in the epitome above and read from the directions in the hosts file, the # symbol is used as a comment, significant that annihilation that follows it is avoided. This is why the two case lines we requite above are useful in this hosts file; they're not beingness followed by that symbol.

Related: Edit Hosts File to Add together Local DNS Lookup

If you desire to cake websites with the hosts file, such as YouTube, Amazon, Google, Reddit.com, etc., y'all tin enter a fake IP accost like 0.0.0.0.

Note: When y'all enter the URL of the site yous want to associate with a specific IP address, be certain to exclude the showtime part and only blazon the subdomain, such equally www or whatever it happens to be for the site y'all're adding.

Saving The Hosts File

Here's how we'll save the hosts file to brand sure it works no affair which operating arrangement y'all use, which text editor you lot picked, or how your Windows settings are configured:

  • Go to File > Save As.
  • Alter the Save as blazon selection to All Files (*).
  • Rename the file to hosts.backupfile, and so save it to your desktop.
  • Shut Notepad and and then detect the hosts file you but created on the desktop. You lot want to delete the .backupfile part of the name and go out just hosts (with no period or text later on the word).
  • Later yous do that, click abroad from the file to something else on the desktop, and confirm the name change when asked.
  • Copy the hosts file.
  • Open up 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 come across them.