Two months earlier, I wrote about how to cure browser viruses. One of the suggested methods was to check the hosts file. Then this issue was covered briefly, but now we will consider it in more detail.
Virus programs very often edit the hosts file, writing certain commands. As a result, access to Odnoklassniki or VKontakte may be lost (sometimes the user opens the “left” VKontakte website with a request to send an SMS to unblock the page), the antivirus will stop updating, or the Internet connection will disappear altogether. It also happens that instead of one site, another one loads. For example, you open the start page of Yandex or Google, and an advertising site appears.
In all these cases, cleaning the hosts file is required. If the reason is the appearance of ad viruses or blocking access in it, then the problem will disappear. Can be done in 2 ways: manually and using programs. And below are instructions on how to fix the hosts file using each of these methods.
How to clear the hosts file manually
Manual cleaning is very simple, as you will now see for yourself.
Click Win + R and copy the line into the window that appears: notepad %SystemRoot%\system32\drivers\etc\hosts. As a result, notepad will launch with the contents of this file.
There is another way to open it:
- Go to the path: C:\WINDOWS\system32\drivers\etc\.
- Right-click on the hosts file and click “Open”.
- Find Notepad in the list of programs and click OK.
Ready. This is what the hosts file should look like:
First there are explanations from the Windows developers about what this file is. Then a couple of examples are given on how to correctly write commands. Comments are written in plain text and do not perform any action (this is indicated by the hash icon # at the beginning of all lines).
But in your case, there will most likely be a lot more text. And without the hash mark, of course. For example, like this:
Line 127.0.0.1 denies access to the specified website. In the example above, these are Odnoklassniki, Meil.ru and the Kaspersky portal. If other numbers are written there, then there is a redirection to some kind of fake site.
To clean the file you need to remove these extra lines. But be sure to look at what the original version should look like so as not to erase anything unnecessary.
By the way, sometimes these extra lines are hidden at the very bottom. That is, when you open the file, it seems that there is nothing there, but if you scroll to the bottom, you can find several virus commands.
Then save the accepted changes. To do this, click File – Save in the notepad.
Restart your computer or laptop – and the problem with ad viruses or site blocking should disappear. If that was the reason, of course.
What to do if you do not have rights to edit the hosts file? Copy it to your desktop, delete the extra lines, save the changes, and then put it in the same folder and replace the previous version. And then restart your PC.
If the problem persists, first check if the changes to the host file have been saved. After all, this is a fairly common mistake of inexperienced users.
The instructions are universal for all operating systems, so its version does not matter here.
How to clean the hosts file?
Hello everyone Let's talk about such a file as hosts, a lot has already been said about it on the Internet, that there may be viruses and all that. Well, there can’t be viruses there, but there can still be dangerous entries. Before I show this file and show you how to clean it, let’s just say in a simple way what kind of file this is?
So look, the hosts file is available both in Windows XP and in all other versions of Windows, so even if you have Windows 10, then all the information that I will write here will be suitable for this Windows.
So it would be closer to the point to say so. The hosts file contains a mapping between the site address and the IP server address. If you don’t know, then I’ll tell you that every site on the Internet, these are all their names, then this is all done for convenience. These are domain names, so to speak. But in fact, the site does not have a name, but the IP address of the server on which it is located. The mapping of such a server and name can be forced in the hosts file, do you understand?
That is, in this file we can register any IP server for a site, and when you enter the site name into the browser, the request will go to the server that was specified in the hosts, that is, the hosts file is a comparison of domain names and The server IP addresses are in forced mode, so to speak. Well, I hope this is more or less clear...
In all Windows, if I'm not mistaken, the hosts file is located in this folder:
C:\Windows\System32\drivers\etc
I didn’t write about one more thing at all. Well, this hosts file can be used for their own purposes by viruses. I think you understand why? These viruses simply do this: they take and write fake server IP addresses for popular sites, for example, VKontakte. Then you go to this VKontakte, and in the address bar you have the original address, that is, not fake, but in fact the server’s IP address has already been set to a different one! And you are transferred to the left server, where exactly the same VKontakte site is located, you don’t notice anything at all, calmly enter your login and password, and at this time the login and password are written to a file on the hacker server, and you are transferred to the original VKontakte login page with some kind of error. Well, you think, well, let me try again, enter your username and password and log in, everything is fine, just sit there.. It doesn’t happen to anyone... But in fact, everything is thought out and your username and password are already written down.. Well, that’s all theory of course and nothing more
You're probably thinking, how do I know all this? Well, I’ve been on the computer for a very long time, I like it all, I also learned a scripting language, and started writing all sorts of programs for myself, although many were never useful. Well, in short, I wanted to say that I’ve been on the computer for a long time, a lot of things were interesting, I read a lot, and as a result, now I know a lot and am happy to share this information with you. But what I described about replacing the server of popular sites, many viruses do this, it is also called phishing, and today modern browsers are fighting this thing and you know, they are doing it very successfully.
Let's open the hosts file, to do this, double-click on the file and then a window will appear where you need to select a program to open the file, here select Notepad:
Well, here's what I have inside this file:
You will probably immediately think, what does this all mean? So look, my hosts file is clean, that is, everyone should have one! The content may be slightly different, I just don’t remember, but on all Windows it should have lines that begin ONLY with the # sign and that’s it, no more lines! The fact is that everything that begins with # is just comments and they are for informational purposes only, understand? They can't do anything, it's just info and that's all. But if there is some site name at the bottom, and opposite there are some numbers separated by a dot (this is an IP address), then your hosts file is not clean! Maybe it makes sense to clean it?
Well, in fact, there may be some entries in the hosts file that are needed for some program to work, but on ordinary computers this is very rare!
But how to properly clear the hosts file? Look, there are two options. The first is to delete everything altogether, yes, yes, exactly everything that is there, you can delete it so that the hosts file is completely clean. Comments, as I already wrote, have only informational value and that’s all. The second option is to delete all lines that do NOT start with the # symbol, that is, in the end you should only have lines that start with #, that is, comments and that’s it.
I deleted everything there, rebooted, all sites work as before. This is what I checked, just in case. My advice is to clean the hosts file, so to speak, to clean it, just delete everything that is inside it, this is, so to speak, a guaranteed cleanup
Well guys, it looks like I wrote everything okay here? I hope so. If something is wrong, then I apologize. Good luck in life and may everything go well
STOP, STOP, STOP! I completely forgot to write that everything is not so simple with this hosts file! What I mean is that you can’t edit it just like that, most likely nothing will work out! And why? And here’s why, look, you deleted everything that was in the hosts file, then you close the file, there will be a message like this, it says whether you need to save the changes, you click Save here:
Well, it seems like everything should be normal, but then you have such a joke, this window appears, and you also click Save in it:
And then you get this crazy error, well, you must admit that it’s crazy and that’s it:
Well, how do you like it? As for me, it’s just nonsense! But in fact, this is not nonsense, the simple fact is that this is a type of Windows security, it does not allow you to change such super important files as hosts, that is, you can ONLY look at it and that’s it, but you CANNOT save the changes. Moreover, you can only change this file if you open it with administrator rights! In short, guys, this is such a pain in the ass that I’ll try to write everything here in a simpleton way and I think everything will be clear and easy for you.
Oh, guys, this is such a pain in the ass. On the Internet, if you suddenly look for information on this topic, then you can find a way that you need to press Win + R, the Run window will appear... BUT, look carefully, when I called up this window, it looks like this me:
That is, this is a SIMPLE window, while for other people, under the field for entering a command, it says at the bottom that the task will be launched as administrator! But I don’t have something like that and I don’t understand why I don’t! Here's the Run window for others:
Well, I mean, I think you understand. I will show a universal method in which the Run window will not be used at all. So, I installed a new clean Windows, where the hosts file was untouched at all. What do we do? We will clear the hosts file completely, that is, we will make it so that it is stupidly empty. At the same time, I will show you how to bypass all these jambs with a ban on editing the hosts file, everything will be normal
Let me remind you that I will do all this in Windows 7, but in other Windows I think it will also work.
The first thing you need to do is remove the Read Only attribute from the hosts file. To do this you go to this folder:
C:\Windows\System32\drivers\etc
Then right-click on the hosts file and select Properties there:
And then uncheck this box:
Uncheck the box, click OK, then another window will appear, then click Continue:
That's it, the first part of the work is done. Now click the Start menu and write cmd at the bottom, then at the top of the results you right-click cmd and select Run as administrator:
Then you will see this security window, here you click Yes:
But your security system may be disabled, then such a window will not appear. In general, then you will see a black window, this is a command line into which you can enter all sorts of commands:
That's it, we have the command line open with administrator rights, this is very good. Now here you need to enter the following command (you can just copy and paste):
start C:\Windows\System32\drivers\etc\hosts
Press enter, then a window will appear where there will be programs that can be used to open the hosts file, well here you select Notepad and click OK:
That’s it, after this your hosts file will open for editing and this is what’s inside it:
This is a clean hosts file, that is, there are no changes in it at all, everything is as it was after installing Windows, everything remains the same. This is, so to speak, its factory condition
Well guys, we opened it, what next? Everything that starts with a hash mark, that is, with the # sign, is all comments. All this can be removed. But how to clear the hosts file completely? Here you just need to delete everything that is inside this file. This is how I do it: I just right-click on the content and select Select All:
Well, then everything will be highlighted and I also right-click on the selected one and select Delete:
That's it, then there will be nothing in the file and you can close it. No, of course you can simply delete it, select everything with the mouse and then delete it. But I click Select All so that not only the letters are selected, but also the spaces, they are not visible. Although yes, it smells a little crazy...
Well, and most importantly, then you close the hosts file, there will be a message like this, you click Save there:
And then EVERYTHING! EVERYTHING HAS BEEN QUIETLY KEPT WITHOUT BIGS, that is, there will be no errors or anything else, everything is normal. And why? Well, because we unchecked the Read only checkbox in the properties of the hosts file and then opened the file itself with administrator rights. Compliance with these two conditions will allow you to edit the hosts file or simply delete all content
That's all guys, I hope that everything was clear to you, good luck in life and that everything goes well.
Home! hosts file 11/11/2016
How to fix the hosts file via AVZ
AVZ is perfect for this - a powerful anti-virus utility that helps clean your PC from viruses and all sorts of advertising nonsense. This program will find the file, even if it is hidden or completely renamed. It's free and you can download it here.
To open AVZ, select the shortcut, right-click and run it as administrator.
After that:
- From the top menu, select File – System Restore.
- In the new window, check the box at line number 13 - “Cleaning the Hosts file.”
- Click on the "Run" button.
The AVZ utility will clean the host file, after which all you have to do is restart your laptop or computer. Everything will take 5-10 seconds. Plus, the program works on any OS: Windows 10, 8.1, 7 and XP.
This is also interesting: How to block sites from children via hosts?
What the hosts file should look like
Now let's figure out what the hosts file looks like and what it represents if you open it. By the way, you should use notepad to open it, since the file itself does not have an extension. Typically the contents of the file look like this:
The last digits (in our case, 127.0.0.1) are the address of the computer on which you opened the file. This is the normal view of the hosts file. If, in addition to this information, something else is written in it, then you will have to edit the file to bring it to its original state.
How to change the contents of the hosts file
If you need to change the hosts file (for example, viruses got into the file), then this can be done very simply. To view the file itself, open it with Notepad, then change the necessary information and save the file. Restart your computer. All changes will take effect immediately.
Remember that to make changes to the hosts file, you must have administrator rights on the computer you plan to work with. By the way, by editing hosts, you can set a ban on visiting certain sites.
In this way, for example, you can protect your child working at the computer from information that is unnecessary for his age. You can register a ban like this: 127.0.0.1 site.ru This entry should go below 127.0.0.1 localhost (next line).