How to change the hosts file

How to change the hosts file

In some situations, you may need to change the hosts file in Windows 10, 8.1, or Windows 7. Sometimes the reason for this is viruses and malware making changes to hosts, making it impossible to go to certain sites and sometimes you may want to edit this file to restrict access to any site.

This instruction details how to change hosts in Windows, how to repair this file back to its original state using built-in system tools and using third-party programs, as well as some additional nuances that may be helpful.

Modify the hosts file in notepad

The content of the hosts file is a set of entries for an IP address and a URL. For example, the string "" (without quotes) will mean that when the address is opened in the browser, it will not open the actual VK IP address, but rather the specified address from the hosts file. All lines in the hosts file that begin with a pound sign are comments, that is, their content, modification, or deletion does not affect performance in any way.

The easiest way to edit the hosts file is to use the built-in Notepad text editor. The most important point to consider is that the text editor must be run as administrator, otherwise you will not be able to save your changes. I will describe separately how to do what is necessary in different versions of Windows, although in essence the steps will not be different.

How to change hosts in Windows 10 using notepad

Follow these simple steps to edit the hosts file in Windows 10:

  1. Start typing "Notepad" in the search box on the taskbar. When the desired result is found, right-click on it and select "Run as administrator". 
  2. From the notepad menu, select File - Open and specify the path to the hosts file in the folder  C:WindowsSystem32driversetc. If there are multiple files with this name in this folder, open the one without the extension.
  3. Make the necessary changes to the hosts file, add or remove the IP and URL matching lines, and then save the file through the menu.

Done, the file has been edited. Changes can take effect not immediately, but only after restarting the computer. For more information on what and how you can change in the instructions: How to edit or repair the hosts file in Windows 10.

Editing hosts in Windows 8.1 or 8

To run Notepad as administrator in Windows 8.1 and 8, from the initial screen with tiles, start typing the word "Notepad", when it appears in the search, right click on it and select "Run as administrator" .

In notepad, click on "File" - "Open", then to the right of "File name" instead of "Text documents" select "All files" (otherwise go to the desired folder, you will see "There are no items that match the search conditions") and then open the hosts file found in the folder C:WindowsSystem32driversetc .

It may turn out that this folder contains not one, but two hosts or even more. The one with no extension should be opened.

By default, this file in Windows looks like the image above (except for the last line). At the top there are comments about what this file is for (maybe in Russian, it doesn't matter), and at the bottom we can add the necessary lines. The first part means the address to which the requests will be redirected and the second, to which requests.

For example, if we add the line to hosts file  , then the classmates won't open for us (address is reserved by the system for the local computer and if you don't have an http server running on it then nothing will open, but you can enter, then the site will definitely not open).

Once you have made all the necessary edits, save the file. (You may need to restart your computer for the changes to take effect.)

Windows 7

To change hosts in Windows 7, you also need to run notepad as administrator, for this you can find it in the "Start" menu and right-click, then select run as administrator.

After that, just like in the previous examples, you can open the file and make any necessary changes to it.

How to change or repair the hosts file using free third-party programs

Many third-party programs for troubleshooting network problems, customizing Windows, or removing malware also include the ability to modify or repair the hosts file. Let me give you two examples: In the free DISM ++ program for configuring Windows 10 features with many additional features, in the "Advanced" section there is a "Host Editor" item.

All you do is open the same notepad, but with administrator rights and open the required file. The user only needs to make changes and save the file. Read more about the program and where to download it in the article Windows 10 Settings and Optimization in Dism ++.

Considering that unwanted changes to the hosts file often appear as a result of malicious programs, it stands to reason that the means to remove them also contain functions to fix this file. There is such an option in the popular free AdwCleaner scanner.

Just go to the program settings, enable the "Reset hosts file" item and then scan and clean in the main AdwCleaner tab. The process will also fix hosts. Learn more about this and similar programs in our review of best malware removal tools.

Create a shortcut to change hosts

If you often have to repair hosts, you can create a shortcut that will automatically start the notepad with a file open in administrator mode.

To do this, right-click on any free space on the desktop, select "New" - "Shortcut" and in the field "Specify the location of the object" enter:

notepad c: windowssystem32driversetchosts

Then click Next and provide a name for the shortcut. Now, right click on the created shortcut, select "Properties", in the "Shortcut" tab, click on the "Advanced" button and specify that the program runs as administrator (otherwise, we will not be able to save the hosts file).

I hope some of the readers find the instruction helpful. If something doesn't work, describe the problem in the comments, I'll try to help. There is also a separate material on the site: How to fix the hosts file.

Creative Stop All About Technology
A How To.