Internet Windows Android

Clean hosts file. Hosts file - where is it located, what should it look like, how to edit and save Hosts file windows 8 no access

In some situations, it may be necessary to change the hosts file in Windows 10, 8.1, or Windows 7. Sometimes the reason for this is viruses and malware that make changes to hosts, which makes it impossible to access certain sites, and sometimes you yourself may want to edit this file in order to restrict access to any site.

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

Many third-party programs for fixing network problems, tweaking Windows, or removing malware also include the ability to change or fix the hosts file. Here are two examples. In the free DISM++ program for configuring Windows 10 features with many additional features, there is a Hosts Editor item in the Advanced section.

All he does is launch the same notepad, but with administrator rights and the necessary file open. The user only needs to make changes and save the file. Read more about the program and where to download it in the article.

Considering that unwanted changes to the hosts file are usually the result of malware, it is logical that tools for their removal may also contain functions to fix this file. There is such an option in the popular free scanner AdwCleaner.


It is enough to go to the program settings, enable the "Reset hosts file" item, and then scan and clean it on the main AdwCleaner tab. In the process, hosts will also be fixed. Details about this and other such programs in the review.

Create a shortcut to change hosts

If you often need to fix hosts, then you can create a shortcut that will automatically launch notepad with an open file in administrator mode.

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

notepad c:\windows\system32\drivers\etc\hosts

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

I hope that for some of the readers the instruction will be useful. If something does not work out, describe the problem in the comments, I will try to help. Also on the site there is a separate material:.

What is a file hosts, where is it located in the Windows 8 (8.1) operating system and how to edit it?

What is a hosts file?

hosts is a text file containing the database domain names which are broadcast in network addresses.

A drop of useful information:

Domain name is a set of characters in a human-readable form that specifies the address of a network resource such as a website, email, and so on. For example, my site is on the domain website.

Network address or IP address is the unique address of a single node in a computer network. IP addresses are either static or dynamic. For example, in the IPv4 version of the protocol, an IP address might be: 192.168.0.1 or 46.42.60.167.

So, in relation to a personal computer, the file hosts stores IP addresses of domain names on the local machine.
The file can be edited manually if necessary, but with administrator rights.
They like to make changes to this file and various malicious programs.

In the Windows operating system (XP, Vista, 7, 8, etc.), the file hosts located in the directory:

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

How the hosts file works

When a user types in the browser's search bar the URL of a website and presses the Enter key, the web browser does the following:

  • Checks in hosts file whether the entered name is a proper computer name (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 IP address for that host, as specified in hosts file;
  • If the hostname is not found in the file hosts, then the browser accesses the DNS resolver cache (DNS cache);
  • If a hostname is found in the cache, the browser looks up the corresponding IP address stored in the DNS cache for that host;
  • If the hostname is not found in the DNS resolver cache, the browser contacts the DNS server;
  • If the requested web page (site) exists, then the DNS server translates the user-specified URL into an IP address;
  • The web browser downloads the requested resource.

How to open the hosts file?

Find and open a file hosts in Windows 8 is not difficult. You can go all the way, as they say, manually. Open the C drive, go to the Windows folder ... and so on.
For a convenient search, it is recommended to use windows explorer, since file managers (for example, Total Commander) for some reason do not see it. To open the explorer, you need to press the Start button or the Windows key or the key combination Ctrl + Esc. Copied file address hosts you need to paste in the search field:

With the same success, you can use the Run window (Windows + R):

You can turn to the third option. Move the mouse pointer to the upper or lower right corner of the screen, calling up the vertical menu, and click on Search:

This file is nominally a text file, but does not have the usual extension. .txt, so the operating system will offer options to open it. In the window that appears, find and select Notebook, and better, Notepad++:

For example in a text editor Notepad++ the hosts file for Windows 8 will look like this:

I tried to translate the contents of the file and this is what I got. Please read carefully, as the content of this file contains the basic rules for filling hosts.

# Copyright (c) 1993-2009 Microsoft Corporation.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains mappings of IP addresses to hostnames.
# Each entry must be stored on a separate line.
# The IP address must be in the first column followed by the corresponding hostname.
# The IP address and hostname must be separated by at least one space.
#
# Also, comments can be inserted on lines (such as this line),
# they must follow the node name and be separated from it by a '#' character.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# Resolution of the localhost name is handled within the DNS itself.
# 127.0.0.1localhost
# :: 1 localhost

Only the last two lines are key in this file, everything else is nothing more than a technical description of an informational nature. These two entries are identical. The first entry is the original IPv4 and the second entry is the local host in IPv6.

File hosts can be used to speed up the Internet and reduce the amount of traffic. This is achieved by reducing queries to the DNS server for frequently visited resources by the user. For example, if you use Yandex and Google search engines every day (sites http://yandex.ru And http://google.ru respectively), then it makes sense in the file hosts below line 127.0.0.1 localhost add the following lines:

93.158.134.11 www.yandex.ru

209.85.229.104 google.ru

This is how it will look in the file hosts:

This will allow your Internet browser not to contact the DNS server, but to immediately establish a connection with sites yandex.ru And google.ru.

The hosts file is sometimes used by the computer administrator to block unwanted web resources. To do this, after the line 127.0.0.1 localhost add a line or multiple lines:

127.0.0.1 blocking resource address-1

127.0.0.1 blocking resource address-2

127.0.0.1 blocking resource address-3

For example:

Impact of malware

As we have already said, a request for a file hosts happens first and then to the DNS servers. It is known that the content hosts file can be controlled by the computer administrator, and when certain conditions are created, unfortunately quite often, malware can also have an impact.

What are the goals of attackers?

  • Blocking access to famous and popular sites;
  • Redirecting the user to other sites (advertising, phishing pages).

As a result, an attacker and fraudster can get access to your data (logins and passwords), cause some damage by taking possession of your information, or worse, money.
If when checking hosts file on your computer is no different from a standard file - so there are no problems.

But malware can add to the file hosts additional entries that are highly undesirable. Always pay attention to the entries after these lines:

# 127.0.0.1localhost
# ::1 localhost

Typically, malicious code is executed after a program downloaded from the Internet is launched. At this point, changes are automatically made to the properties of the browser shortcut and quite often additional lines are added to the file. hosts.

To block a resource, the following lines are entered:

127.0.0.1 Resource URL

This is the same as we covered in the Restrictions… section, only it will be executed by the malware. And you will not be able to visit this web page because it is blocked on your computer.

To redirect to another site in a file hosts an entry like this is added:

157.15.215.69 Resource URL

In this case, after entering the URL of the desired resource in the browser, the user will be redirected to a completely different site, the purpose of which can only be guessed at.

By restore, I mean going back to the original or default state.
In fact, the entire standard hosts are the last two lines, everything else, as you already know, is a simple description.


It must be remembered that apart from these entries, nothing else should be present in the file. Everything superfluous must be immediately deleted, of course, if you yourself did not add anything to the file hosts.
After making changes, save the file.
Can a standard file hosts for Windows 7, 8 and replace the damaged one in the C:\Windows\System32\drivers\etc\ folder.

If the above steps fail:

  • There may be an issue with permissions. You need to run a text editor with administrator rights and through the menu File → Open find the hosts file and edit.
  • It is advisable to disable real-time anti-virus protection. Many modern antiviruses prevent changes to the file. hosts.
  • Enable display of extensions for registered file types, hidden files, and system files.

There are no more words. Everything! All the best and light to you! Bye. L.M.

After entering the desired site in the browser, suppose Google.com , the browser sequentially (according to priority) looks for a mapping of this domain name to an IP address (because network devices work with IP addresses).

but) the specified site is checked in the hosts file, if it finds a match (suppose 1.1.1.1 Google.com is written in the hosts file), then the contents of IP - 1.1.1.1 will open accordingly, if there is no specified domain name, proceed to the next step;

b) the dns cache is checked (if you previously opened Google.com, then most likely the IP of this site was stored in the DNS cache of your computer / laptop), if the site IP is indicated there, then the page opens for you, if not, it proceeds to the last stage;

in) the request goes to the DNS server (it is registered manually in the network connection settings or issued via DHCP), if the specified site is not in the DNS server, it will "ask" another DNS server until it finds it (if, of course, it exists at all) and the site is successfully will open.

The hosts file is located along the path C:\Windows\System32\Drivers\etc\hosts (if C is the system drive). You can open it with regular notepad. If you have not made changes to the hosts file, then the following will be written there:

hosts file in Windows XP:
# Copyright (c) 1993-1999 Microsoft Corp.
#
#


#space.
#

#
# For example:
#

127.0.0.1 localhost

hosts file in Windows Vista:
#
# 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

hosts file in Windows 7:
# 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

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

hosts file in 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.1localhost
# ::1 localhost

As you can see, regardless of the version, the host file does not differ much, but if a virus "worked" on the hosts file, various sites and IP-shniks can be added there. For example:

127.0.0.1 ftp.kasperskylab.ru
127.0.0.1 ids.kaspersky-labs.com
127.0.0.1 vk.com
127.0.0.1 drweb.com

Such additions to the file prevent you from accessing the specified sites.

1.2.3.4 ftp.kasperskylab.ru
1.2.3.4 ids.kaspersky-labs.com
1.2.3.4 vk.com
1.2.3.4 drweb.com

Such additions to the file when opening the specified sites will redirect you to other sites, possibly infected with viruses (IP-1.2.3.4- are fictitious).

If you find that the hosts file has changed, you need to fix it. In Windows XP, the file is simply opened in notepad, the necessary changes are made and saved (you must be logged in as an administrator). On other versions (Windows Vista, 7, 8) you need to give permission to modify the file. To do this, open the folder in which hosts is located C:\Windows\System32\Drivers\etc(if drive C is system). Right click on hosts and choose "Properties".

Choose a tab "Security", then select the user under which you work on a computer / laptop (in this example, this is a website) and press the button "Change". A window will open "Permissions for group "hosts"", select the user again and assign full rights to the file, click "OK", in the window "Properties: hosts", too "OK".

After that, open hosts with Notepad and return the file to its original state, when finished, save the changes.

When you connect to a website, your computer first contacts the DNS domain name server and requests the IP address of the desired site. For example, the site Facebook.com corresponds to the IP address 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 change the behavior above. By editing the hosts file, you can "bind" Facebook.com to any desired IP address. Some people use this trick to block websites.

So, for example, you can link Facebook.com to 127.0.0.1, which is your local IP address. Subsequently, if someone on your computer tries to contact Facebook.com, 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 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 malware, adding various lines to it. So, for example, a Trojan can “attach” 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 guess that he is on a phishing site.

To prevent this, Windows 8 (or more specifically Windows Defender in Windows 8) monitors your hosts file. When you add a site to it, like vk.com, the operating system immediately deletes the new entry and thus 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're a do-it-yourselfer, you can turn off tracking changes to the hosts file.

Because Windows Defender monitors changes to the hosts file, you can:

  • Exclude hosts file from Windows Defender tracking. This is the best way. However, using it will mean that Windows will no longer protect your hosts file from being modified by malware.
  • Install third party antivirus. Many third party antiviruses will not 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 entirely, but that's not a good idea (unless, of course, you install a third-party antivirus afterwards). Even being a careful user, having multiple layers of protection is 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, 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 the Browse button and navigate to the following file:

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

Click the Add button and save your 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, when you save it, 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 menu File -> Open 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 hit the space or tab button 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 reboot required.

That's all! Good luck to you!

Hosts (domain database) is a small document located in the Windows system folders. When you surf the Internet, or simply go to a website through your browser bookmarks, Windows first accesses it. The main purpose is to match site names (domains) and their IP addresses, written as numbers. You can go to the site by entering a domain or ip.
It is vulnerable to viruses and other malware that seek to rewrite it

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

How to open hosts

The database of hosts is in any OS capable of connecting to the Internet. Both on Windows, and on MacOS, and on LInux distributions. But the location is very different. In XP, Vista, 7 and 8, 8.1 and 10 the hosts file is located at C:\Windows\System32\drivers\etc. You can open it directly in the explorer. The system32 folder is right there in Windows.

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

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

It will start in the usual notepad. If the command line was initiated from the admin, then the notepad 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 one you need. In order for notepad to see it, you will 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 it is needed.

How to change hosts in Windows 8 or 8.1

The content of hosts 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, adding or deleting addresses.

The line 127.0.0.1 localhost is the local machine you are working on. If the http server is not running on the computer, you can use the 127.0.0.1 address to block unwanted sites. Add the line 127.0.01 site.ru (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. A restart of the computer is required. If you managed to change the hosts file in Windows 7, the added sites will not work until you delete the entries about them and save them. On the contrary, if the malware has added its own entries, you can remove them, thereby opening access to the necessary sites or deleting entries about redirecting to resources that steal passwords, extort money or infect the computer.

Editing hosts in Windows 7

Changing hosts in Windows 7 is no different. It lies at the same address, edited with a notepad through administrator rights. Sometimes it is not possible to change the hosts file. The reason is in viruses: some rewrite and do not allow you to change hosts. Therefore, before trying to overwrite and save, check your computer for viruses. It is desirable 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, select "Create" -\u003e "Shortcut".
fig.1. In the 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 Notepad.

  • Click on "Next" and give the shortcut a name 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 administrator

Now you manage domains and IP addresses on your computer.

WATCH VIDEO

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