What to do if there is no hosts folder. The HOSTS file in the C:\Windows\System32\drivers\etc folder is damaged: what to do

System hosts file is a text file that contains a local database of domain names and their IP addresses. A request to the hosts file has higher priority than access to DNS servers. Various viruses or malware take advantage of this, replacing its contents with their data.
Where is the hosts file located?
By default, system file hosts located in the directory .
To get to it you need to go to the menu StartExecute or press the key combination WIN+R. In the window that opens Starting the program enter the address:
C:\Windows\system32\drivers\etc
or
%WinDir%\system32\drivers\etc
Press the button Enter.

To open it, right-click on it and select the item in the menu Open with notepad
What should be in the hosts file by default?

Hosts file for Windows XP:

# Copyright (c) 1993-1999 MicrosoftCorp.# # # space.

# # # For example: # 127.0.0.1 localhost

Hosts file for Windows Vista: # # Copyright (c) 1993-2006 MicrosoftCorp. # # 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 # # Copyright (c) 1993-2006 MicrosoftCorp. # # 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: # Hosts file for Windows 7:

# Copyright (c) 1993-2009 MicrosoftCorp.

127.0.0.1 localhost ::1 localhost # # Copyright (c) 1993-2006 MicrosoftCorp. # # 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: # Hosts file for Windows 8:# Copyright (c) 1993-2009 Microsoft Corp.

# localhost name resolution is handled within DNS itself.

What files are in the C:\Windows\System32\drivers\etc directory, and what are they responsible for?

First, let's take a look at the files in this folder. In addition to the file you are looking for, there should be only four more objects located here. If there is something else, we can safely say that or something similar.

Regarding file functions, for example, the C:\Windows\System32\drivers\etc\services object and other files, including HOSTS, protocol, lmhosts and networks, are responsible for some functions of user access to certain resources on the Network.

The one in question determines the mapping of a database of domain names to IP addresses. In addition, its use involves speeding up user access to the most frequently visited pages on the Internet, bypassing DNS servers, as well as blocking some unwanted resources or banner links. By default, in addition to the descriptive text part, it contains one single entry of interest to us at the end of the text, namely: 127.0.0.1 localhost. All! There should be no more additional entries in it.

Checking the IP address of sites

If we talk about the example of a domain name matching the real IP address of a resource, you can check it in a completely elementary way by using the standard input of the ping command on the command line, followed by the URL of the resource being checked, separated by a space.

To obtain the IP of any resource, you must use the following combination: ping www.(site name).(domain affiliation). For example, for the Facebook network this would look like ping www.facebook.com. After executing the command, the desired address and statistics of the so-called ping will be displayed on the screen.

What to do if the file is infected with a virus?

Unfortunately, it is the C:\Windows\System32\drivers\etc\HOSTS file that viruses infect most often. After this, when the user logs into the same social network, he is either redirected to a clone site, or a message is issued requiring payment for the login. Let’s make a reservation right away: not a single “social network” charges money for using the services of the resource. Hence the conclusion: it is a virus (sometimes artificial blocking, which is extremely rare).

If such a disaster has happened, you should first check your computer system. In some cases, you should not even use the antivirus installed on the system, since it has already missed the threat, and there is no guarantee that it will detect it and remove it as a result of an on-demand scan.

It's better to run some portable utilities like Dr. Web (Cure IT is best!) or KVRT, which does not even require installation. But even such powerful products do not always help, and blocking access to resources written in the C:\Windows\System32\drivers\etc\HOSTS file remains and continues to work. Let's see how we can get rid of it.

Correcting file text manually

First, go to the directory C:\Windows\System32\drivers\etc, then select our file and right-click to call up the menu with the command “Open with...” (initially, the system file itself will not open by double-clicking because it does not have an extension) . Now, from the list of available programs, select the standard “Notepad” and look at the contents of the text.

As a rule, an infected file may contain entries like 127.0.0.1, after which the addresses of resources of the same “social networks” are indicated (for example, 127.0.0.1 odnoklassniki.ru). This is the first sign that they were produced as a result of the activation of malicious code. It turns out that the control elements of the system, referring to the HOSTS file, are constantly producing when trying to access it.

The simplest fix is ​​to delete all content when you paste the original text (you can take it from another computer or find it on the Internet). After this, you just need to save the changes (Ctrl + S) and restart the computer terminal. You can, of course, try to replace the file you are looking for with the original one, but it is unlikely that the system will allow you to do this even if you have administrator rights. In addition, this option works in about 20-30% of cases.

Problems with HOSTS and the lmhosts.sam object

The problem can often be more serious. The fact is that sometimes when entering the C:\Windows\System32\drivers\etc directory, the HOSTS file we need is visually missing.

First, in Explorer, you should use the service menu, and then select the folder options, where the option to show hidden objects (files and folders) is enabled. In addition, you need to uncheck the boxes for hiding protected system files and extensions for registered types. Now our file is visible.

However, this is where the real problems begin. The fact is that when you try to edit or save, the system displays a message that the file C:\Windows\System32\drivers\etc\HOSTS is not writable. What to do in this case?

We take drastic measures - delete the HOSTS file, preferably from the Recycle Bin. You can quickly delete it, bypassing the Trash, using the combination Shift + Del. Then right-click on the free space of the window and select the command to create a new text file and call it hosts or HOSTS without an extension, as you wish, it does not matter. We agree with the system’s warning regarding changing the extension and begin editing. As is already clear, the further steps are similar to the previous option - simply insert the original content and save the newly created document. After this, we delete the lmhosts.sam file (it is this that affects the performance of the desired host file), after which we again reboot the system.

This option will restore access to your favorite sites that were previously blocked. By the way, this method almost always works.

Instead of an afterword

As can be seen from the above, you can fix the problem with blocking Internet resources quite simply, even without having any special knowledge and skills for this. However, before you start editing the HOSTS system object, you should make sure that a standard scan with anti-virus software did not yield anything. Some users try to use utilities like Microsoft Fix It. Please note that if there is a virus in the system, the files will be re-infected, and the corrections will only be made temporarily.

What's happened hosts file? This question is usually asked by newbie users who know about the existence of such a file only by hearsay. Few people know that this file is used for their own purposes by virus writers, and even fewer are those who use this file on their computer for their own benefit. Meanwhile, it is very important that you have at least some idea about the file hosts and even more important that any user knows how to handle it correctly.

Problems such as: " I can't log into VKontakte." or " Doesn't fit into classmates?"and similar ones in half the cases (if not more) are associated precisely with changes made in the file hosts. Another question is who makes such changes. In most cases, of course it is viruses, which replace the original hosts file on your computer or add their information to it. All this will be discussed in this article.
First, I’ll tell you about the file itself. hosts and what it serves for.

Hosts. What it is?

In fact hosts is a text file that contains a database domain names compared with their IP addresses. In other words, the address of any domain initially has the form of an IP address. One IP address can host several virtual servers, so there can be several websites on one IP. IN hosts The default file contains only one ip address (127.0.0.1), which is reserved for localhost, i.e. for your local (namely your) computer.
Myself hosts file on your computer is located at the following address: (table source: Wikipedia)

operating system Versions Location
Unix and Unix-like /etc/hosts
Windows 95, 98, Me %windir%\
NT, 2000, XP, 2003, Vista, 7 %SystemRoot%\system32\drivers\etc\ , its location can be overridden in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\DataBasePath , which contains the path to the folder.
Windows Mobile Registry key \HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts
Mac OS 9 and earlier System folder: Preferences or just in the system folder
Mac OS X and iPhone OS /private/etc/hosts or /etc/hosts (/etc on Mac OS X is a symbolic link to /private/etc)
Novell NetWar SYS:etc\hosts
OS/2 and eComStation "bootdrive":\mptn\etc\
Symbian OS 6.1-8.1 C:\system\data\hosts
9.1+ Z:\private\10000882\hosts
Android /system/etc/hosts

Hosts file has no extension, but is easily edited with text editors (for example Notepad)

Hosts. History of origin.

When computers were very large, and the Internet was still very small, even then, for the convenience of users, hosts were assigned names. There were few hosts back then. To map text names to IP addresses, it was necessary to send a request to the main host, which sent a list of all names and addresses. This file ( host file) was regularly sent to all computers connected to the Network. As the Global Network developed and expanded, the number of hosts, servers, and users increased, and the host file. There were significant delays in registering and obtaining a name for a new computer connected to the Network. Too much time was spent on mailing host file... To solve these problems, it was created DNS– Domain Name Service. ABOUT hosts file forgot for a while...

Hosts. Principle of operation.

Request to hosts file has priority over access to DNS-servers. Unlike DNS, the contents of the file are completely controlled by the computer administrator. What happens when an Internet user types a website address (url) in the address bar of his browser and clicks go ( Enter) ?
The browser contacts DNS a server that converts this regular address into the IP address of the requested server. At this moment the browser status bar says: “ Search for a node..." If the requested node is found, the text “ Node found, response awaited...", and is installed TCP connection via the standard port for this service. Step by step, more clearly to the question “ What happens when an Internet user types the site address (url) in the address bar of his browser and presses go (Enter)?"You can answer that:

  1. browser accesses hosts file and checks whether the site name matches the computer’s own name ( localhost) i.e. Is the site's IP address equal to the local IP address? 127.0.0.1 ;
  2. if not equal, then checks hosts file for the presence of the requested address (host name);
  3. if the requested address (hostname) is in hosts file, then the browser goes to the host (ip address) specified in this file;
  4. if the requested address is in hosts file not found, the browser accesses the DNS resolver cache ( DNS cache) ;
  5. if the requested address (hostname) is found in DNS Cache e, then accordingly the browser accesses DNS server y;
  6. if such a web page (site) exists, then DNS server translates url V ip address and the browser loads the requested site page.

So we found out why and How does it work hosts file . Now let's see what it contains.

Original hosts files. Default contents of hosts files.

Below I will provide the text that should be contained in hosts file by default, i.e. original hosts file.

Windows XP

# Copyright (c) 1993-1999 Microsoft Corp.


#102.54.94.97 rhino.acme.com

# source server

# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

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

# Additionally, comments (such as these) may be inserted on individual

# lines or following the machine name denoted by a ‘#’ symbol.

127.0.0.1 localhost

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

# Additionally, comments (such as these) may be inserted on individual

# lines or following the machine name denoted by a ‘#’ symbol.

# 102.54.94.97 rhino.acme.com # source server

# # For example: #

# localhost name resolution is handled within DNS itself.

# 127.0.0.1 localhost

# ::1 localhost

Using the hosts file for your own purposes.

Hosts file can be used to reduce the number of requests to DNS server am for frequently visited resources, and this in turn will reduce traffic and speed up the loading of frequently visited resources. For example: you often load the sites google.ru and google.com. Opening hosts file using Notepad and after the line 127.0.0.1 localhost add:
209.85.229.104 google.ru
74.125.232.20 google.com

Before adding, read below the rules for editing the hosts file

This action allows the browser to immediately, without contacting the DNS server, establish a connection to the sites google.ru and google.com.
Besides hosts file can be used to block access to unwanted resources on the Internet (adult sites, spam sites, sites with malicious software, etc.). This can be done just as easily by adding immediately after 127.0.0.1 localhost next line
127.0.0.1 url of the blocked_resource.
In this way, the resource address is mapped to the IP address of this computer, and therefore the resource will not load.
After all changes, when exiting the notepad, save the result.

Rules for editing the hosts file

  • Each element must be located on a separate line, i.e. when adding a new address, be sure to move to a new line (press Enter);
  • The IP address must start from the first position of the line (let's say so at the beginning of the sentence), must be followed (on the same line) by the corresponding resource address (hostname);
  • The IP address and resource name must be separated by at least one space;
  • Comments must be separated by # (lattice) ;
  • If comments are used in domain name matching strings, they must follow the host name and be separated from it by the character # (lattice) ;

We've sorted out the editing rules. Now let's look at how virus writers and viruses use the hosts file for their own purposes.

Use of the hosts file by virus writers.

Those who write viruses have long appreciated the possibilities hosts file and actively use them to their advantage. Viruses replace your hosts file or they edit it in such a way that when you type a certain address (usually the addresses of popular sites), not the site you had in mind opens, but one that looks similar to it, but is actually a site of attackers and distributes malicious codes. In addition to redirecting to their sites, they also block access to the site while extorting money from you in order to re-open access. Attackers mainly use blocking on social networks.
On the Internet in many forums you can find thousands of user questions like: “ I can't log into Contact. What to do?" or " Why can't I log in to Odnoklassniki?" or " I can't log into Facebook. Profile is blocked. What to do?". All these problems begin as a result of the fact that you caught a computer disease somewhere. virus and he edited your file hosts. I already wrote about this in the article and will not repeat it, (fortunately, it describes how to fix all this, and therefore I advise you to read this article to the end as well), but I’ll describe the situation when this file hosts I can’t find the address on my computer at all. I will explain clearly with an example windows 7. Let's say you go to a folder and see this picture:


As you can see from the picture, in this folder hosts file absent ( file lmhosts no need to touch). In fact, it is there, the virus just changed the file attribute to “ Hidden" or " System". I wrote about the “Hidden” and “System” attributes.
By default, in the folder options there is a checkbox next to the setting “ Do not show hidden files, folders and drives". We need to change this parameter to " Show hidden files, folders and drives". To do this, click Start—> next Control Panel—> next Folders settings View". Here at the very end we rearrange the button with “ Do not show hidden files, folders and drives" on " Show hidden files, folders and drives«.


Now going to the folder C:\WINDOWS\system32\drivers\etc we see that hosts file on the spot.
Sometimes hosts file cannot be edited due to viruses on the computer. In such cases, you can simply delete the hosts file and then create it again yourself. To create hosts file, in folder C:\WINDOWS\system32\drivers\etc create a simple text document and call it hosts(I hope everyone knows how to do this). The result will be a text document with the extension .txt(hosts.txt). And as we already know the hosts file has no extension. This means we remove the extension from the name. We do not see the file extension in the name because in the default system configuration the extension for registered files is hidden. Well, let's break it down.
To do this, click again Start—> next Control Panel—> next Folders settings(in XP “Folder Options”). In the window that opens, go to the second tab “ View". Here (just above the line “Do not show hidden files, folders and drives”) uncheck the " Hide extensions for registered file types". Having done this we will see the file name hosts along with the extension .txt. Now we change the name and remove the unnecessary ones, namely .txt.
IN windows 7 x64 to find the hosts file you may have to go to the line “ Start - execute» (details about commands) type the command:
cd\windows\system32\drivers\etc\ and then launch notepad with administrator rights to open hosts.
Those who cannot or do not want to create a hosts file themselves can download it from our website. Here are the links:
Original file hosts For
Original file hosts For
Original file hosts For

Afterword:
Phew... It turned out to be a voluminous article. I think it will be useful to you, both in terms of theory, knowledge base, and in practice.
That's all. I look forward to your comments.

Some terminology

DNS(English abbreviation for Domain Name System) – Domain Name Service. Establishes correspondence between numeric IP-addresses and text names.

DNS(English abbreviation for Domain Name Server) – domain name server; a service computer on a local or global network that translates computer names in domain records into .

DNS cache(resolver cache DNS) – temporary storage of previous DNS-requests on local . Reduces request execution time, reduces network and Internet traffic.

host(English) – main computer; host, any device connected to a network and using protocols TCP/IP.

IP(English) Internet Protocol) – Internet protocol; a network layer protocol from the Internet protocol suite.

IP address(English) IP address) – used to identify a node on a network and to determine routing information. Consists of the network identifier ( network ID) and host ID ( host ID).

Name Resolution(English) – domain name resolution; the process of converting a computer name to the appropriate one.

Name Resolution Service– name resolution service; in networks TCP/IP converts computer names to and vice versa.

TCP/IP(English abbreviation for Transmission Control Protocol/Internet Protocol) – information transfer control protocol, the main protocol of the transport and session layers, providing reliable full-duplex streams.

Designed for use in the Global Network and for combining heterogeneous networks.(English abbreviation for URL Uniform Resource Locator

What's happened hosts) – unified index of information resource; a standardized string of characters indicating the location of a resource on the Internet.

-filehosts Windows-file in (and other operating systems is used to associate (map) host names (nodes, servers, domains) with their).

name resolution hosts IN-by default there is only one registered in the file localhost(127.0.0.1), reserved for.

, that is, for local hosts File

is a regular text file (without extension). hosts:

Windows 95\98\Disk address of the fileM.E.;

\WINDOWS\\2000\ \ \ – Windows NT.

\Windows\System32\drivers\etc\ Designed for use in the Global Network and for combining heterogeneous networks. When an Internet user types the address ( Enter:

) of any site (web page) and clicks hosts– the user’s browser checks localhost);

– if not, then the browser looks for the requested address (hostname) in the file hosts;

– if a hostname is found, the browser accesses the corresponding hostspecified in hosts-file;

– if the hostname is not found in the file hosts , then the browser accesses ( DNS-cache);

– if a hostname is found in the cache, the browser accesses the corresponding host, saved in cache DNS;

– if the hostname is not found in the resolver cache DNS, the browser accesses DNS-server;

– if the requested web page (site) exists, DNS-server translates user-specified Designed for use in the Global Network and for combining heterogeneous networks.-address in ;

– The web browser loads the requested resource.

History of origin hosts-file

# Copyright (c) 1993-1999 Microsoft Corp.

#

#

#space.

#

#

# For example:

#

127.0.0.1 localhost

# 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

127.0.0.1 localhost ::1 localhost

#

# 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

Hosts file for Windows 8:

# 127.0.0.1 localhost

# ::1 localhost

Usage hosts-file

hosts-file can be used to speed up work on the Global Network and reduce traffic - due to reduced requests to DNS-server for frequently visited resources.

For example, you often download resources google.ru And google.com. Open the file hosts and after the line127.0.0.1 localhost enter lines

209.85.229.104 google.ru

74.125.232.20 google.com

This will prevent the web browser from having to contact the server DNS, and immediately establish a connection to sites google.ru And google.com.

Sometimes hosts-file is used to block unwanted resources (for example, those that send malware). To do this you need after the line 127.0.0.1 localhost enter string

127.0.0.1 URL_of_resource_blocked

The essence of this manipulation is that the blocked resource is mapped to127.0.0.1, which is the address of the local computer - so the unwanted resource will not be loaded.

Editing rules hosts-file

1. Each element must be on a separate line.

2. must begin at the first position of the line and must be followed (on the same line) by its corresponding hostname.

3. and hostname must be separated by at least one space.

4. Comments must be preceded by the symbol # .

5. If comments are used in domain name matching strings, they must follow the host name and be separated by # .

Usage hosts-file by virus writers

Attackers have long since taken a fancy to hosts-file, – with its help the real addresses of web resources are replaced on the infected one. After this, the web browser redirects the user to sites with malicious software, or, for example, blocks access to the sites of antivirus manufacturers.

Malicious disguises modification hosts-file as follows:

– to make it difficult to detect lines added by a virus, they are written to the end of the file - after a large empty area formed as a result of repeated line translations;

– after that to the original hosts-the file is assigned an attribute Hidden(by default, hidden files and folders are not visible);

– a false one is created hosts- a file that, unlike a real file hosts(without extension) has extension .txt(by default, extensions are not displayed for registered file types):


hosts-file: how to eliminate the consequences of a virus attack

Open hosts-file (if the virus installed the fileattribute Hidden, will be required in Folder properties enable option Show hidden files and folders) ;

– a window will appear Windows with a message "The following file could not be opened...";


– set the switch Selecting a program from the list manually –> OK;

- in the window Program selection in scrollable list Programs highlight Notepad –> OK;

– file hosts will open in Notepad;

– delete all lines except 127.0.0.1 localhost;

– save hosts-file.

Valery Sidorov

What is the Hosts file for?
The purpose of this system file is to assign certain website addresses to 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 of Windows OS, the 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 versions of Windows, but not much. It “writes” in English why it is needed and how to make exceptions, giving one example. All lines starting with a # sign mean that they are commented out and do not affect the file.
Contents of the original hosts file 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, there are no significant differences in the contents of the host file for different versions of Windows.

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 writing 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 visit a site, you see its 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 you cannot access the site using standard means.

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 test.ru into the address bar of your browser, 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 the window to the bottom. This is due to the fact that some viruses are registered in an area hidden outside the window.
  • In some cases, usually if you cannot save the file, you need to log in under the Administrator account.
  • 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.

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