Clean hosts file.  The hosts file - where it is, how it should look like, how to edit and save Where is the host file in Windows 8

Clean hosts file. The hosts file - where it is, how it should look like, how to edit and save Where is the host file in Windows 8

Hosts (domain database) - a small document that sits in the Windows system folders. When you go online and or just go to the site through your browser bookmarks, Windows first of all addresses it. The main purpose is to match the names of sites (domains) and their IP addresses, written in numbers. You can go to the site by entering domain or ip.
It is vulnerable to viruses and others malware who seek to rewrite it

This is done so that you automatically get to advertising and viral sites or to block the ability to download some Internet services. But fortunately, the content of Hosts is controlled by the user. A notepad program is enough to enter data into the text editor or save it from unnecessary things. How to change hosts in Windows, read on.

How to open Hosts

A host database is included in any OS that can connect to the Internet. And on Windows, and on MacOS, and on LInux distributions. But the location is very different. On XP, Vista, 7 and 8, 8.1 and 10 hosts file located at C: \ Windows \ System32 \ drivers \ etc. Can be opened directly in the explorer. The system32 folder is right in Windows.

But it's easier to open a command line from the list of standard programs and enter this in the window: notepad C: \ windows \ system32 \ drivers \ etc \ hosts and press Enter.

Run the command line with administrative rights, otherwise only view will open, and the change will be blocked.

It will start in a familiar notebook. If command line was initiated from the admin, then the notebook will open in the same way and you can make edits.

There is a third way to open the hosts file in Windows 7, 8, 10 - for the curious:

  1. in explorer go to C: \ Windows \ system32;
  2. you need notepad.exe;
  3. right-click on it and click on run as admin.

Further, in a simple way: "File" -> "Open" and look for the desired one. In order for the notebook to see it, you need to enable the "All files" option in the lower right corner of the window. So, we figured out how to open hosts as an administrator, it's time to understand how to edit it and why you need it.

How to change hosts in Windows 8 or 8.1

The hosts content in Windows 7, 8 and 8.1 is the same and looks something like this

If you know English well, then at the top you can read a small text about the purpose of the file, but for sure you will have it in Russian. We will edit the lower part by adding or deleting addresses.

Line 127.0.0.1 localhost is the local machine you are running on. If the http server is not running on your computer, you can use the address 127.0.0.1 to block unwanted sites. Add the line 127.0.01 site.ru (the address of the blocked resource). You can add as many lines as you like.

Listed sites will not open in any of the web browsers on the local machine

The method is suitable for prohibiting access to sites dangerous for children. For the changes to take effect, you need to save the hosts file. Computer restart required. If you change the hosts file in Windows 7, the added sites will not work until you delete the entries about them and save. On the contrary, if a malicious program has added its own entries, you can delete them, thereby opening access to the necessary sites or erasing redirection entries to resources that steal passwords, extort money or infect your computer.

Editing hosts in Windows 7

Changing hosts in Windows 7 is no different procedure. It lies at the same address, edited with a notepad through administrator rights. Sometimes it is not possible to modify the hosts file. The reason is viruses: some overwrite and do not allow changing hosts. Therefore, before trying to overwrite and save, check your computer for viruses. It is advisable to use several programs in turn for an accurate result. There is a large selection of anti-virus scanners on the Internet that do not require installation on a hard drive.

Create a shortcut to edit hosts

  • To quickly open the domain database, you can place a launch shortcut on the desktop.
  • Right click on an empty desktop.
  • Next, you need to select "Create" -> "Shortcut".
fig. 1. In the item location of the object, write the line: notepad c: \ windows \ system32 \ drivers \ etc \ hosts

It means that the file at the specified address will be opened by the Notepad program.

  • Click on "Next" and assign a name to the shortcut so that it opens the desired file with administrator rights.
fig. 2. On the finished shortcut, right-click again and in the properties of the shortcut go to "Advanced" and indicate the requirement to run as an administrator

Now you manage domains and IP addresses on your computer.

WATCH THE VIDEO

Now you know how to change the hosts file in Windows. Ask questions to specialists.

The article highlights such questions: where is the hosts file in Windows 7, Windows 8, Windows 10; the contents of the hosts file, how to edit it; how to save the hosts file if access is denied.

The hosts file - what is it, what is it for?

What is it

hosts - a file containing a database of IP addresses and domain names corresponding to them. For example, for the popular VKontakte site, the match will be as follows:

87.240.131.118 vk.com

The hosts file on Windows is opened with an application Notebook.

What is it needed for

The letter site addresses were invented exclusively for people, since it is easier for a person to remember this. Computers find sites by numbers. Using the example of the same VKontakte: vk.com is an alphabetic address (or they say, a URL), and 87.240.131.118 is a digital one (or an IP address).

Check my words. In the address bar of your browser, enter
87.240.131.118
You must get to the site https://vk.com/.

All correspondences between IP addresses and URLs are stored on DNS servers, with which the browser contacts and opens the desired site to us.

But before contacting the DNS server, the browser always checks the hosts file. In it, we can prohibit the opening of sites, or replace the correspondence between the IP address and the URL.
This is what viruses do on the computer, replacing matches, adding other lines to this file, etc. For the lines that need to be entered into such a file, see the chapter “How to enter commands

How the hosts file should look. Contents of the hosts file

The hosts file should contain the following:

For Windows XP:

# Copyright (c) 1993-1999 MicrosoftCorp.
#

#




# space.
#


#
# For example:
#

127.0.0.1 localhost

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


# 127.0.0.1 localhost
# :: 1 localhost

For Windows 7, 8, 8.1, 10:

# 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

Where is the hosts file in Windows 7, Windows 8, Windows 10

The hosts file lies in all versions of Windows at
See screenshots:

How to open the hosts file

This file is opened with Notepad. We find this application in the start menu. Right-click. In the menu that appears, select "Run as administrator". In the opened Notepad window, through the "File" → "Open ..." menu, open the hosts file, writing the file address in the address bar of the window that opens, or moving from folder to folder until we find it.

How to edit the hosts file

1. Recovery

To restore a file you need:
  1. Open the file with notepad as administrator.
  2. Copy the contents of the file from this article, paste and replace, and save.
Attention!
The file should only be opened through Notepad running as administrator. Otherwise, the changes will not be saved. When we save the .txt extension in the file name, delete it.

Tricks of the modified hosts file

1. Some viruses to mask their changes after lines
127.0.0.1 localhost
:: 1 localhost

leave a lot of spaces and only then add lines.

Therefore, when replacing content, select all content (hotkeys CTRL + A).

2. The file is hidden
If there is no file in the specified package, then it may have been hidden and assigned the "Hidden" attribute.
In the menu View → Options → View, check the box "Show hidden files, folders and drives."




Now that the file has appeared, uncheck the "Hidden" checkbox in the file properties.

3. Cannot be edited
The file was assigned the read-only attribute. Uncheck the corresponding checkbox in the file properties.


Into the folder C: \ Windows \ System32 \ drivers \ etc put a file named hosts, but with the extension .txt(hosts.txt file) or no extension, like the hosts file, but with a different name, for example, host.

2. Change

To block access to a site, you need to enter the lines at the end of the content
(Line skip)
127.0.0.1 (multiple spaces) (Blocked Domain Name)
127.0.0.1 (multiple spaces) (Blocked domain name from www.)

Using the example of the same VKontakte and Odnoklassniki:


We save. We check our work by entering the URL of these sites into the address bar of the browser. Websites do not open. Bingo!

Thus, it is possible to block the sites of computer games, casino sites, pornographic sites, etc.

To redirect, we do everything as before, but give the desired URL a different IP.

Example. Let the site https://vk.com/ open when entering VKontakte and Odnoklassniki
We write the lines:
(Line skip)
87.240.131.118 vk.com
87.240.131.118 www.vk.com
87.240.131.118 ok.ru
87.240.131.118 www.ok.ru

2.3. Popular sites and their IP addresses

87.240.131.118 https://vk.com/
213.180.193.3 https://ya.ru
5.61.23.5 https://ok.ru/

The Internet is full of services to determine the IP addresses of any sites. Google it.

hosts access denied - what to do

If you cannot save the file and access is denied. We do it in turn, trying to save the file after each item.
  1. Open it in Notepad as administrator.
  2. Copy the file to your desktop. Change it. The hosts file left in the folder C: \ Windows \ System32 \ drivers \ etc rename to hosts.old. Copy the edited hosts file on the desktop to the folder C: \ Windows \ System32 \ drivers \ etc.
  3. Turn off antivirus. Antiviruses often make sure that no changes are made to this file. Add file to Windows Defender exclusions. Starting with version 8, Windows makes sure that no one changes this file.
  4. Set access rights to the file in its properties on the "Security" tab.
  5. If the uninstallation fails anyway, go to Safe Mode and try to remove from under it.

What happens if you delete the hosts file

There will be nothing. Unless there will be problems with the Internet connection. During the connection, the IP address 127.0.0.1 will have to be specified manually. It is possible that some programs will ask for localhost instead of 127.0.0.1, which will create another problem.

The changes in Windows 8 also affected the hosts file. Now block some sites, including many famous social networks editing the file will not work, as was possible in previous versions of Microsoft operating systems. Why does this happen?

What are hosts?

Before connecting to a website, the computer first requests the IP address of the resource. Once it recognizes it, the computer connects to the IP address and accesses the web page. Hosts is a local file for the computer. In it, you can edit the addresses of sites, so that access to them can be closed.

For example, Vkontakte can be tied to any IP address, including your own. Then, when trying to access this site from a computer, he will not be able to find a web service and, accordingly, go to this resource. In this regard, hosts are used to prevent programs from connecting to developer services if a pirated version of the utility is used. In case of a virus infection of the hosts file, you can learn from this article how to remove the Hosts virus that blocks access to certain sites.

Why is the file handling changed?

Developers in Windows 8 tried to establish maximum protection against various malicious programs. There are often situations when viruses make various changes in them. Because of this, the user can be on a phishing service without even realizing it.

In the new operating system, Windows 8 Defender makes sure that no changes are made. On the one hand, this is not bad, as it minimizes the risk of getting to third-party sites that infect your computer with a virus. However, there is also a negative side, because you will not be able to block access to unwanted sites on your own. But the latter can be corrected, and in several ways.

How to fix hosts in Windows 8

The easiest way to fix hosts in Windows 8 is to make a copy of it, fix it, and then put it back. To do this, go to drive C, find the Windows / system32 / drivers / etc folder. It must be copied to any place, for example, to the Desktop. After that, open it using the standard Notepad program.

We make the necessary changes to it. After that, we save the file and send it back to the folder from which we took it. To do this, you need to agree with its replacement. Actually, this is enough to make changes. However, this method is not always suitable. Therefore, other methods can be used. For example, exclude hosts from tracking the Defender program or disable Defender. Detailed instructions you will find how to enable and disable Defender in Windows 8.

To exclude hosts from tracking, we first find a utility. In the search, enter Windows Defender. Open the application and go to the Settings folder. This is where you need to find the Excluded Files and Locations section. In it, follow the link Overview. In the list that opens, select the hosts file. We click on the Add button, after which we confirm the changes made.

After you have done the steps described above, you can edit the hosts file, and the operating system will not ignore it. In addition, you can make changes if you have administrator rights, and if not, then you need to first. In this case, you need to right-click on the Notepad icon. In the list that opens, select run as administrator.

To edit the hosts file, you can use not only Notepad, but also other editors, such as Notepad. After you make the necessary changes, the web resources will be blocked. You don't even need to restart your computer for editing to take effect. Often, editing the hosts file helps to deny access to certain resources, which can sometimes be very important.

When connecting to a website, your computer first contacts the DNS domain name server and requests the IP address of the desired website. For example, Facebook.com has an IP address 66.220.158.70. Then your computer connects to the learned IP address, and gets access to the site.

Your hosts file is a file local to your computer that can change 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 contact Facebook.com from your computer, your computer will try to connect to itself. However, it will not find the web server for you, and therefore there will be no connection.

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

Why did Microsoft change how the hosts file works?

Unfortunately, the hosts file is often edited by malicious programs, adding various lines to it. For example, a Trojan can "bind" Facebook.com to a completely different IP address, which will contain 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 guess what is on the phishing site.

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

For many users, this behavior operating system very important, because it is aimed at their own safety. However, being a fan of doing everything yourself, you can turn off tracking of changes in the hosts file.

Due to the fact that Windows Defender is responsible for tracking changes in the hosts file, you can:

  • Exclude hosts file from being tracked by Windows Defender... it the best way... However, using it will mean that Windows will no longer protect your hosts file from being modified by malware.
  • Install a third-party antivirus... Many third-party antiviruses will not treat your hosts file as aggressively. When installing a third-party antivirus, Windows Defender will turn itself off.

You can also turn off Windows Defender completely, but that's not a good idea (unless, of course, you install a third-party antivirus after that). Even as a careful user, having multiple layers of protection is good security practice.

Exclude the hosts file from being tracked by Windows Defender

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

On the left, in the search results, select Windows Defender and open the app.

On the "Options" tab in the "Excluded files and locations" section, click on 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 won't ignore your changes.

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, while saving, you will see an error message with the words about insufficient rights.

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

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 a line for each blocked site. Type 127.0.0.1 then press the space or tab key 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. Changes will take effect immediately and websites will be blocked - no system restart is required.

That's all! Good luck to you!

For everyone who has problems with this file !!! The file was checked by Kaspersky, Node 32, Doctor Web - everything is clean! Download the file, unzip it, copy it to the Windows / system32 / drivers / etc directory (if Windows asks for permission to substitute files, we agree, if it writes an error that you are not an Administrator, try replacing the file using the Total Commander program) and enjoy life. The file fits all the latest operating systems:
  • Windows XP
  • Windows Vista
  • Windows 7
  • Windows 8 and 8.1
The file is required mainly for those who do not open any sites in contacts, as well as for those who cannot access anti-virus sites or update antiviruses. Description of the file. Downloading is completely free, no annoying SMS. An article on how to create a hosts file yourself, the article can help you solve your problem.
Also, one of the users provided us with their host file so that you can use it.It blocks all malicious and advertising sites that can harm your computer. We express our gratitude to the user Diman8369 for providing such a file.

Create and Modify a Host File in Windows XP

Windows 7, 8, 8.1 and 10


About 8 thousand computers a day are infected with Trojan Hosts

Doctor Web has reported an increasing number of hacked sites in order to download malicious programs from the Trojan.Hosts family to users' computers. The scale of the spread of this threat at the beginning of 2013 became almost epidemic. Trojan.Hosts spreads peaked in January and mid-February, when about 9,500 infections were recorded on users' computers every day. In March, Trojan.Hosts infect about 8,000 computers a day.


To hack sites, cybercriminals use the FTP protocol, connecting to resources using previously stolen logins and passwords. Then a special command interpreter (shell) is loaded onto the compromised site, using which the .htacess file is modified, and a malicious script is placed on the site.

As a result, when entering an infected site, the script displays the visitor a web page containing links to various malicious applications. In particular, Trojans of the Trojan.Hosts family have recently begun to spread widely in this way.

The main purpose of malicious programs of the Trojan.Hosts family is to modify the hosts file located in the system Windows folder and is responsible for translating network addresses of sites. As a result of malicious actions, when trying to go to one of the popular Internet resources, the user of the infected computer is redirected to a web page belonging to the cybercriminals.