How to fix the hosts file in windows 8.1. Clean hosts file. Editing the hosts file

Of course, the performance of any operating system has its own subtleties and nuances, and this is especially true for everything related to the Internet. And a file such as hosts in Windows 8 is no exception.

Special purpose

To understand how to edit hosts in Windows 8, you first need to understand why such a file is needed at all and what it is responsible for.

Like most everything that exists, the Internet is far from what it seems to the average user at first glance. The average owner of a personal computer or laptop is used to opening a browser, entering search bar request and receive the information found or the necessary Internet page. But in fact, the PC had to perform where more work, than the user managed to notice.

As soon as the desired query or address has been entered, the system turns to one important tool - the DNS server. It is responsible for determining and issuing IP addresses to websites and plays the role of a kind of buffer between certain personal computer with its operating system and internet page. Once the request has been sent and the necessary information has been received, the connection to the website server and direct downloading begins.

The hosts file in Windows 8 plays the role of a protective membrane through which specified IP addresses are passed and unknown ones are cut off.

It has local significance and its own original copy is created on each device with an operating system from Microsoft. And, despite the fact that in most cases it has the same parameters, anyone can change them at their own discretion, of course, with the appropriate knowledge and skills.

It is through this file that you can prohibit connections to certain servers, which will allow you to deny access to content that is undesirable for the user. Also, editing it can be used as “parental control”.

Setting details

Before describing where the hosts file is located in Windows 8, you should describe the nuances associated with it.

The first thing worth mentioning is that this file is the most common target for virus and spyware. The malicious program tries to make changes and add new entries that allow you to connect not to the desired website, but to a pre-prepared one that will sabotage your PC. The effect will depend on the intended purpose of the virus, its type and the tools at its disposal. Thus, the owner of the device may not even realize that he did not go to the VKontakte page, but to a completely different server, since the address bar will contain the words “vk.com”.

The hosts file, due to its importance, is under the protection of a service such as Windows Defender, which does not allow you to make adjustments to it or add new entries.

When installing third-party antivirus software, this service is disabled, and control over the hosts is exercised by the newly installed utility. The degree of control decreases as third party application is more tolerant of working with local data.

If necessary, the user can remove Defender custody of this file, but this should only be done by experienced users who understand what this can lead to. To do this, you need to open Windows Defender, go to the “Settings” tab, and then select the file of interest in the block of excluded files and locations, which is located at: C:WindowsSystem32Driversetchosts.

Hosts adjustment

At the preparatory stage, you will have to perform one small but very important action, without which further manipulations simply do not make sense. Editing the required object is impossible if:

  • Windows Defender protection was not removed. All changes simply will not function, since the operating system will refuse to make adjustments and save them.
  • No third party antivirus was installed software. It has noticeably fewer tools in the environment than the native Defender, and therefore its control will be less soft. This, in turn, will allow the PC owner to correct the file in the key he needs and save the changes.

Having finished with the preparatory stage, you can move on to the main procedure.

First of all, you need to launch standard Notepad or any other simple text editor.

As soon as the corresponding window is displayed on the monitor screen, select the “File” tab in the upper right corner, and then the “Open” position and follow the previously mentioned address.

Once the file is open, you can start making new parameters. To do this, you need to go down to the end of the entries and new line first add your local IP, and then the Internet address of the resource itself. The local IP address has a general meaning and in standard form looks like this: 127.0.0.1.

Once the data is entered, all that remains is to save the changes and check the results of the work.

Hosts file in Windows 8: Video

When connecting to a website, your computer first contacts the DNS domain name server and requests the IP address of the desired site. For example, the website Facebook.com has an IP address of 66.220.158.70. Your computer then connects to the identified IP address and accesses the site.

Your hosts file is a file local to your computer that can modify the above behavior. By editing the hosts file, you can “bind” Facebook.com to any IP address you want. Some people use this trick to block websites.

So, for example, you can bind Facebook.com to 127.0.0.1, which is your local IP address. Subsequently, when someone tries to access Facebook.com from your computer, your computer will try to connect to itself. However, it will not find your web server, and therefore there will be no connection.

In a similar way, the connection of programs to activation servers is blocked so that “wrong” keys found on the Internet do not stop working.

Why did Microsoft change how it works with the hosts file?

Unfortunately, the hosts file is often edited by malware, adding various lines to it. For example, a Trojan can “link” Facebook.com to a completely different IP address, which will host a specially prepared hacker server that can impersonate the real Facebook.com. The user will see the name Facebook.com in the address bar and will never even realize that they are on a phishing site.

To prevent this, Windows 8 (or more accurately windows defender on Windows 8) monitors your hosts file. When you add any site to it, like vk.com, the operating system immediately deletes new entry and thereby ensures your connection to the normal site vk.com.

For many users, this behavior of the operating system is very important, because it is aimed at their own security. However, if you like to do everything yourself, you can disable change tracking host file s.

Since Windows Defender monitors hosts file changes, you can:

  • Exclude hosts file from Windows Defender tracking. This best way. However, using it will mean that Windows will no longer protect your hosts file from being modified by malware.
  • Install an antivirus from a third-party developer. Many third party antiviruses won't be as aggressive with your hosts file. When you install a third-party antivirus, Windows Defender will turn itself off.

You can also disable Windows Defender completely, but this is not very good idea(unless, of course, you install a third-party antivirus after this). Even as a cautious user, having multiple layers of protection is a good security practice.

Excluding the hosts file from Windows Defender tracking

To exclude the hosts file from being tracked by Windows Defender, first open Windows Defender itself. To do this, enter in Windows search Defender.

On the left, select Windows Defender from the search results and open the application.

On the Options tab, in the Excluded Files and Locations section, click the Browse button and navigate to the following file:

If you installed Windows in a different folder, start there instead of C:\Windows.

Click on the “Add” button and save the changes.

Now you can edit your hosts file, and Windows will not ignore the changes you made.

Editing the hosts file

You will have to edit the hosts file as an administrator. If you try to edit it in the usual way, when saving you will see an error message saying that you do not have sufficient rights.

To run Notepad as an administrator, right-click on it and from the menu that appears, select the option to run as administrator.

By the way, you can also use any other editor, like Notepad++, to edit the hosts file.

In the editor, click on the File -> Open menu and navigate to the following file:

C:\Windows\System32\Drivers\etc\hosts

In the file selection window that opens, you need to select the “All files” option from below, otherwise you will not see the hosts file.

After opening the file, add your own line for each site to be blocked. Type 127.0.0.1 then press the spacebar or tab and then write the name of the website. So, for example, the following lines will block facebook.com and vk.com:

127.0.0.1 facebook.com

127.0.0.1 vk.com

After editing, save the file. The changes will take effect immediately and websites will be blocked - no system reboot required.

That's all! Good luck to you!

What is the Hosts file for?
The purpose of this system file- assigning certain website addresses a specific IP.
This file is very popular with all kinds of viruses and malware in order to write their data into it or simply replace it.
The result of these actions may be signs of “insertion” of a site into browsers, which will ask to send an SMS when opening the browser, or blocking of various sites, at the discretion of the creators of the virus.

Where is the hosts file in windows?
For different versions Windows OS location of the hosts file is slightly different:

Windows 95/98/ME: WINDOWS\hosts
Windows NT/2000: WINNT\system32\drivers\etc\hosts
Windows XP/2003/Vista/Seven(7)/8: WINDOWS\system32\drivers\etc\hosts


Moreover, the ending hosts, this is already the final file, not a folder. He doesn't have it.

What should the correct hosts file look like?
The "contents" of the hosts file are also slightly different for different windows versions, but not really. It is "written" in English language why it is needed and how to make exceptions with one example. All lines starting with a # sign mean that they are commented out and do not affect the file.
Content original file hosts for Windows XP:


#

#




#space.
#


#
# For example:
#



127.0.0.1 localhost


Contents of the original hosts file for Windows Vista:

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
#space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a "#" symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost::1 localhost


Contents of the original hosts file for Windows 7:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
#space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a "#" symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handle within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost


Contents of the original hosts file for Windows 8:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
#space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a "#" symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost


As you can see, the contents of the host file for different versions Windows, there are no special differences.

How to open and edit the hosts file?
The hosts file can be found in standard Windows Notepad.
This is probably the most interesting part of the article.
First of all, you need to understand why change this file at all? Yes, in order to deny access to certain sites. Thus, by changing this file and having entered the site address into it, the user will not be able to access it through any .
In order to change the hosts file, it is advisable to open it as administrator () by right-clicking on the file and selecting "Run as administrator". Or open Notepad this way and open the file in it.

For quick action, you can simply click the Start button and select Run ( win+r) () and enter in the line:

notepad %windir%\system32\drivers\etc\hosts



As a result, this file will open in Notepad.

In order to block access to the site(let's assume it will be test.ru), you just need to add a line with this site at the very bottom:

127.0.0.1 test.ru


As a result, the file will have the following content:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
#space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a "#" symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# This HOSTS file created by Dr.Web Anti-rootkit API

# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 test.ru


Each new site that you want to block must be started on a new line and entered, not forgetting the local IP address 127.0.0.1

Also, to edit the hosts file, there is a program HOSTS EDITOR, which you can download and read the description from.
The way it works is that it helps edit the hosts file.
From the screenshot below the principle of its operation is clear; everything is done in a couple of clicks. Adding is done by clicking on +.


After editing, do not forget to click on the save button (2 button "Save changes" to the left of the "+" button).

You can also change this file for good purposes, for example speed up site loading.
How it works?
When you access the site, you see it Domain name, which has letters. But all sites on the Internet have an IP address, and names are already assigned using DNS. I will not go into details of this process, this article is not about that. But here you need to know that the hosts file has priority when accessing sites, and only after it does a request to DNS occur.
In order to speed up the loading of a site, you need to know its IP address and domain.
The IP address of a site can be found using various services, for example or.
A domain is the name of a website.
For example, let's speed up the loading of this site where you are reading an article by explicitly specifying the IP address and domain to the file.
Then the added line will be:

91.218.228.14 website


This speeds up page loading in a couple of seconds, and sometimes can give access if standard means You cannot access the site.

Still possible redirect to another site using hosts file.
To do this, you need to know the IP address of the site and its domain (as in the case described above), then the added line will be like this:

91.218.228.14 test.ru


And now, after entering address bar browser of the site test.ru, you will be redirected to the site specified in the IP address..

If you want to clean hosts file, then you can do this by simply deleting the content and inserting the original text from the description above (under spoilers).

Some nuances in the hosts file:

  • Always make sure you have a scroll bar on the side and always scroll to the bottom of the window. This is due to the fact that some viruses are registered in an area hidden outside the window.
  • In some cases, usually if you can’t save the file, you need to log in account Administrator.
  • Sometimes, due to viruses, this file may be hidden. Read the article.
  • The two methods described (redirection and acceleration) may not produce the desired result. The fact is that several sites can be located on one IP address, this is especially true for external IP addresses provided by services.
  • Due to the fact that viruses love this file, its attributes can be changed to Hidden And Read-only.
  • Check the file attributes if the hosts file cannot be saved.

    This way you can easily and free of charge block access to sites in Windows by editing the hosts file.

  • 1. What are hosts for?

    The task of the system hosts file is to store a list of domains (web addresses like site.ru) of various sites and their IP addresses. Thus, in the process of working with the Internet, domains are converted into their IP addresses and vice versa. Each outgoing request to open a particular Internet site is, in fact, a request to convert a domain to an IP address. This query is performed by the Internet DNS service. From the technical side of the Internet veil, there are no web addresses in literal expression like site.ru. They are used for the convenience of web surfing by users and reflect the essence of the site's themes. Designed to facilitate the exchange of data between different parts of the network, the DNS service converts domains into specific sets of numbers, also known as the IP addresses of each individual site.

    The hosts file has priority over the DNS system. Before accessing this Internet service, browsers first check their cache, then receive information about the correspondence of IP addresses to domains, which is contained in the hosts file of the operating system Windows systems. And only after this the request goes to DNS.

    Some users make changes to the “hosts” in order to speed up the loading of their favorite sites. If you specify in it for individual sites the correspondence of IP addresses to their domains, you can get slightly faster access to these sites, since they will load in the browser window, bypassing the stage of sending a request and receiving data from the DNS service. But this method of optimizing Internet access is not necessary, since there is a browser cache with the highest access priority.

    The need for intervention to change the contents of this file arises when it is edited by malware without the user’s knowledge. Hosts file - vulnerable Windows place, it causes the creators malware special interest. By replacing the original system hosts file with its analogue, but with a ready-made list of false correspondences of IP addresses to their domains, Internet fraudsters thus implement a redirection mechanism that is beneficial to them. If we add a false correspondence of the IP address to the domain into the “hosts”, replacing the real IP address, for example, of some social network with the IP address of, say, a site with paid porn content, then every time we try to get into the social network we will actually end up on a porn site. But this is not the worst example of scammers manipulating hosts. Things will be much more difficult with filling out forms on phishing sites. In order to fish out confidential user data, for example, accounts in financial and online payment systems, logins and passwords for them, Internet fraudsters can replace individual web pages of these online systems with their own web pages, specially created for fraudulent purposes. Substitution of file data with redirection to another site is also used as a dishonest way to promote sites, to block social network pages and extort for unblocking money, to block access to web resources of anti-virus software products, etc.

    Making changes to hosts is also practiced for the purpose of locally blocking access to certain sites. For example, within the framework of parental control.

    Below we will look at how the processes of making changes to hosts are carried out in order to edit it to block individual sites, as well as to correct it in the event of replacing the content with malware. But first, of course, let’s find the file itself, open it and look at its original contents.

    2. Path to the hosts file and opening it

    To access hosts, you must have administrator rights. It is located in the Windows system directory along the path:

    C:\Windows\System32\drivers\etc

    You can also open this path with the command %systemroot%\system32\drivers\etc in the Run dialog box

    To open a file, call up the context menu on it, select “Open with” (simply “Open” for Windows 7) and from the list of offered programs select the standard Windows notepad or any third-party notepad, if one is present in the system (Notepad++, AkelPad, etc.). P.).

    If according to specified path(subject to the display parameter being set hidden folders and files in Explorer) there is no “hosts” file, this is a clear consequence of the tricks of malware that has penetrated the computer. Viruses and Trojans can sometimes move it to another location on the computer.

    3. Contents of hosts

    After opening hosts, we will see its contents in the form of informational information about the essence of this file. Of the correspondence between IP addresses and their domains, only one should be present in the original version of the file contents (without user intervention, without malware tricks) work record. This is a disabled IP address match current computer value "localhost", local host. The hash sign at the beginning of the line means that the prescribed correspondence does not affect anything, but simply exists in the prospect of being used or as a template.

    4. Blocking access to individual sites using the hosts file

    Editing “hosts” is one of the many ways to block access to individual sites. Against the background of the locking mechanisms offered by the regular parental control Windows and third party programs, editing hosts is simple and in a fast way restrictions on access to sites.

    To block access to a specific site, first clear the cache of the browsers used on the computer, then in the hosts open in notepad below the existing entries, enter a redirection from unwanted sites to the local host like this:

    127.0.0.1 site1.ru

    127.0.0.1 site2.ru

    127.0.0.1 site3.ru

    Those. in each match, after the local IP address 127.0.0.1, we add the domains of unwanted sites separated by a space. After editing the contents of the file, click the menu “File” - “Save As”.

    It will not be possible to save the newly created file directly along the path where it is located in the system directory. First, this file must be saved in any non-system folder (for example, in the “Documents” folder) as a regular text TXT file called “hosts”.

    After saving, select this file, press the rename key F2, delete the “.txt” extension (along with the period) and press Enter.

    We confirm the action.

    We copy the newly created file, after which we go to the folder along the path of the original hosts file, which is indicated in paragraph 1 of the article. Before inserting the newly created hosts file, you need to decide what to do with this file in its current edition. As an alternative to deleting, you can use the same F2 key to rename the current file, adding a postscript to the name in the form of a serial number, date or other nuances. It will be something like backup copy hosts with some current settings, which you can always return to by giving the file the original name without a postscript.

    We confirm the insertion of the new file with administrator rights.

    After all these steps, the sites included in the blocking list will not open in any browser on the system.

    In the future, to temporarily remove the lock, so as not to delete entire records, you must insert a pound sign at the beginning of the line of each individual match and save the hosts file as indicated above.

    It is not recommended to create a huge list of blocked sites (more than a hundred) in hosts, so as not to slow down the operation of your computer with the Internet. When blocking large-scale web projects such as social networks, you must also take into account that they may be accessible not by one domain, but on several.

    5. How to fix the hosts file

    If, when you try to visit the desired site, some other one opens instead, or a message appears demanding money for unblocking a social network account, it’s time to fix the hosts. First, of course, you need to clean your computer from viruses and other malware. Only after this can you begin to correct the file. Fixing hosts means that you need to return its contents to its original state. There are several ways to do this.

    One way to fix it is to manually remove strings of false matches between IP addresses and domains that were introduced by malware. Having opened the file in Notepad, we leave only the default matches, as indicated in the screenshot, and delete all other lines.

    And save the file as indicated in the previous paragraph of the article.

    Entries with false matches may be hidden outside the view of the standard notepad window, so you need to view the entire document by scrolling down to the very bottom.

    Another option for fixing a file is to completely replace the existing content with the original text content. The source text of the file can be copied on the Microsoft support site, where options for different versions and editions of Windows are presented in separate blocks:

    In the case of Windows 10, a variant of the source text of the hosts file for Windows 8.1 is used.

    We copy the original contents of the file on the website, in Notepad press Ctrl+A to select the entire text of the document, then Ctrl+V to paste. We save the file as indicated in the third paragraph of the article.

    If the file in the path specified in the first paragraph of this article is missing, it must be created there after neutralizing the malware. Open in notepad new document, paste the source text copied from the Microsoft support site, save the file and place it in the system directory where it should be.

    Finally, last method file corrections are automatic. True, it is only available for Windows 7 and earlier versions of the system. By following the link above, on the Microsoft support website in the “Easy fix” block, download the Fix it utility.

    We launch it, agree with license terms, click “Next”.

    We wait for its completion and close it.

    Reboot the computer.

    The utility will automatically correct hosts and return its contents to its original state, including restoring the file if it was not found along the installation path due to malware tricks.

    Have a great day!

    Vladimir Skesov

    Well, I think you have already noticed that when you try to save a system file hosts(C:\Windows\System32\drivers\etc\hosts), the new operating system complains and does not allow you to save the desired changes. This is to blame for the tightening of safety regulations applied in operating systems eighth episode. Of course, this makes sense, since many viruses write the lines they need into this file, and all antiviruses have long been required to check this file for these changes. But what should we do? ordinary users? We want, for example, to simply turn off advertising in Skype. It's quite simple: we need to open this file in a program running as administrator. And there are several ways to do this:

    I. Editing the hosts file using the command line.

    1) Right-click on the lower left corner and select " Command line(Administrator)":

    2) In the window that opens, write (or copy) the following text:

    notepad C:\Windows\System32\drivers\etc\hosts

    3) The most common Windows notepad will open, but it will be launched with administrator rights and will allow you to make changes to the hosts file:

    An alternative to the first method:

    Download the editHOSTS.cmd file. Right-click on it, select “Run as administrator” and edit the file in the notepad window that opens.

    II. Open a text editor with administrator rights manually.

    1) Fundamentally this method no different from the previous one, but now we need to go to the folder in which the text editor executable file is stored, for example Windows Notepad(this part of the instructions will also apply to other text editors, for example Notepad++) is located in:

    C:\Windows\system32

    You need to find a file in this folder notepad.exe:

    2) Click on notepad.exe right-click and select "Run as administrator":

    3) Select "File" → "Open". In the window that appears, go to the folder with the file hosts(C:\Windows\System32\drivers\etc\). Select "All files" in the lower right corner and open