The host file in windows 7. What is the hosts file. How to open Hosts

I categorically welcome you, now we will talk about the hosts file in our beloved operating system   windows 7 and windows 8. I will tell you where it is located, how to edit it, why it is needed and what it is responsible for. So, let's begin.

Why do I need a hosts file

This file takes its roots from the very inception of the Internet, when symbolic addresses (domains) could be associated with an ip address, only with the help of this file. Now the situation has changed dramatically and DNS is responsible for this. When you enter the site address in your browser, it is checked first of all hosts file   for the presence of the entered site, if it is present, then you will be redirected to the ip address that is specified there. Further I will tell how it can be used and how attackers use it.

It is important to note that the corresponding domain was previously created on the test server. Inside this folder, open the drivers and open them and so on. Now you will see several files from which hosts. From there, Notepad is launched, which contains information about host files. To edit a file, you must first open the editor when the administrator is working. Click Start, type Notepad, but don’t click Notepad to open it. Rather, right-click the list of editors to access the context menu.

Where is the hosts file

This file is located on system drive   in the folder with windows, or rather:

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

Using the hosts file

And so if you are a website developer or just want to create a website, you probably know packages like Denwer or OpenServer. After you create the folders with the domains on the local machine, these packages will be written to the hosts file your local ip 127.0.0.1. After that, all the requests that you send to the created domain will go to your computer and be processed by the local server.

Select the Administrator option. If you do not have local settings for the site on your computer, you only get an error page in your web browser. Obviously, you can see how they can be used in different ways: prank, child safety, etc. if you do not want to block the site this way, you can also redirect to another website.

To do this, simply open the input prompt and enter the following command. Now, where will the hosts file be located - or are there even two files? But where is this directory located on disk? This is where the confusion begins. Quite the contrary. The requirement of two different system directories 32 was resolved by redirection.

Now, consider the second case when attackers gain access to your file using their software (viruses, trojans). As an example, when the addresses of popular websites such as VKontakte or classmates are written in this file, and now every time you log into your favorite social network, you will be informed that your account is blocked and you need to send SMS, although in fact, your profile is not blocked, and you get the data from a third-party server whose ip address is specified, just in the hosts file.

How to get and edit hosts file

The procedure is a bit tedious. Here's how to do it with a 64-bit Notepad.

  • Select "All Files" in the lower right corner.
  • Make changes and save them.
If you want to access hosts from a 32-bit process, use one of the following paths. Please note that in both cases the full path must be used.

Why do I need a hosts file

Thus, this host file performs local checks very well regarding name resolution. However, there are also many more scenarios when processing a host file becomes necessary. The file is always in the directory. And this is the one that has no file endings.

How to change (edit) hosts file

This file is no different from txt files and it can be edited with any text editor, whether it is notepad or notepad ++. To do this, double-click on the file and select the desired one from the list of programs, in our case notepad.

How the hosts file looks in Windows 7 and 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

There is no hosts file. How to create?

Knowing what should be the default in this file, for those who are in the tank - this is the point above. It is possible to restore it, say after a virus infection, if the antivirus did not do it, which now record the changes in this file. Proceed to rehabilitation:

In this case, we recommend that you always select "Editor". After calling the host file, you will see a similar image. This file contains host name mappings. Each entry must be kept on a separate line. In the main file, you can add, edit or delete additional entries. If you want to add another entry.

After making all the changes, you must save the changes to the host file. This is not easy because you should not just overwrite the file. This is the easiest way to save the file to your desktop using Save As. Be careful, however, that you do not attach the file while saving it. Again, you will receive a warning that the file should be overwritten. After you have confirmed the option “Replace file to target”, another request will appear because access to the target folder is denied.

  • Open folder C: \\ Windows \\ System32 \\ drivers \\ etc   in the conductor. Duplicate the file, just in case.
  • Open notepad and copy the standard content, which is located above.
  • Now the most important thing is to select "Save As", specify the location folder standard file, select all files and write the name hosts. Now you can click save and agree to have the program replace the previously created file.


This question is also answered by the "resume". Users can block ads through a system file, for example, if you use the appropriate free software that often annoys ads or protects children from unwanted sites before traveling. Changes in system files   should be handled with care. As a last resort, you can make Internet access on your own computer more difficult. Double-clicking will bring you to a menu where you must select the appropriate software.

If you make the necessary changes at the end of the file, a surprise will occur. You cannot just make adjustments to Notepad and accept them. It is also not related to write protection. Decision. Just go to the previous metro using the “Start” button and enter “notepad” or “editor” on the keyboard. There is an option “Open as administrator”. Then you can make and save all the changes as usual. After a reboot, Internet redirects are activated. You can find a similar method, but with large quantity   explanations on this site.

The article covers such questions: where is the hosts file in Windows 7, Windows 8, Windows 10; 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 a popular VKontakte site, the correspondence will be as follows:

87.240.131.118 vk.com

This process is very simple, and you can play it in ten minutes without serious complications. It consists of two main stages. If this folder or any of the parent folders or these files are not visible on your system, make sure that in the folder settings you have configured the display of hidden files. Now pay attention to one important detail. If you are not an administrator, you will receive a message with the message "Please check if this file is open in another program" or something like "you do not have permission to save in this place, permission to request an administrator."

Windows hosts file opens using application Notebook.

What is it needed for

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

Check out my words. IN address bar   write browser
87.240.131.118
You must go to the site https://vk.com/.

Frauds with hosts file

To open as an administrator, you can first open Notepad in administration mode. To do this, right-click the Notepad icon in the program menu and select "Run as Administrator". The changes to this hosts file that you must enter are very simple. You have some examples of syntax that should be used, but it's pretty simple.

Fix “Access Denied!” Error 403

We will add a few lines at the end. Then we have a second virtual host associated with the virtual host that we just created. There you will see a couple of data that you should edit. In short, it would be to change some lines in the Directory block. In this other configuration, error 403 disappeared.

All correspondences between IP addresses and URLs are stored on the DNS servers with which the browser communicates and opens the site we need.

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

Opening a newly configured virtual host

Dozens of websites solve the same problem and offer several other configuration options that you can try if this causes this access error. In this case, everything is set up for you. Very well. The main advantages that we can modify this file are.

We must remember that in order to edit this file we must be system administrators. By default, we will see a window similar to the following. By default, this file does nothing, but we can change it to our taste in order to be able to fully use it.

What the hosts file should look like. Hosts file content

The hosts file should contain the following:

For Windows XP:

# Copyright (c) 1993-1999 Microsoft Corp.
#

#




# space.
#


#
# For example:
#

127.0.0.1 localhost

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

Where is the hosts file

The result of a file with two previous changes will be the following. Some viruses and trojans are programmed to modify this file, blocking anti-virus web pages and redirecting some sites to others. We must also bear in mind that if we add too many entries to this file, we will be able to generate an excessive load of processes in our system, which will not slow down the Internet connection and, instead of being useful, we will damage.

After you have changed the file with the appropriate settings, click "Save in the menu." In this case, you should use method 2. Once you find the file, right-click it and open it with a record. Click “Save” to apply the changes.

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

You can find a similar method, but with additional explanations on this site. Editing a computer hosts file can be useful to block access to websites without using any applications. In addition, the user can also check if the computer was infected with some trojan, whose common tactic is to block access to anti-virus pages and redirect sites from banks to online traps. Check out the tips and learn how to edit and enable.

Editing the hosts file

After making the necessary changes, just save the file. In this case, just click on the magnifying glass in the upper right corner of the screen and enter “terminal”. Use the arrow keys to place the mouse cursor on the last line and add the site that you want to block.

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

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


How to open hosts file

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


Check out the second step to learn how to block the website. If you find links to anti-virus sites and banks, this may indicate that your computer is infected with malware. In this case, update your antivirus and run a full scan.

How to edit the hosts file

However, if you are having problems due to a recent change, here's how to get the file back to default so that everything works as it once did. After that, click the Start menu and enter Notepad. When the program appears in the menu, right-click on it and select the option “Run as administrator” and authorize the program.

How to edit the hosts file

1. Recovery

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

Tricks of the modified hosts file

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

leave a lot of spaces and only then add the lines.

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

Go to the folder where the file was downloaded and run. If a security warning screen appears, click the Run button to start the application. On the first screen of the program, select the “I agree” check box, and then click the “Next” button.

Location of the hosts file in Windows XP

Wait for the program to finish processing. Then click the Close button. Then the program will prompt you to reboot the system. To confirm, click “Yes” and wait. Often, to solve specific problems on the computer, some users ask a friend for help or look for answers in discussion forums over the Internet. However, the advice is not always clear enough.

2. 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, select the “Show hidden files, folders and drives. "




Many of these manuals found on the network have information that asks the user to edit the host system to move forward. However, for many people, such a recommendation is simply incomprehensible. Now the solution to your problems will come true soon. The first step is to access the system command.

This is a host computer file. All lines refer to some functions, and those marked with a sharp are only examples and are not recognized by the system. To modify a file and insert a new command, you must add it to the last line of the file. However, always remember that the same template is used.




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

3. Cannot be edited
The file has been assigned the Read Only attribute. In the file properties, uncheck the corresponding box.

In addition, the changes vary depending on the needs of each user. Therefore, insert only what the guide indicates. To disable the modification, just add a sharp one at the beginning of the line or just delete it completely. Finally, save the document and you're done.

The difference, however, takes the form of access. You can replace it with another editor of your choice, which is installed on your computer, simply by changing the access form. Also note that there is a space separating the first two members. After editing, save the file for the changes to take effect. If you don’t know which one to use, try as described to see if the system recognizes the command. It is useful for you to be able to access your site without registering or transferring a domain and for some reason cannot use an alternative access address.



To folder C: \\ Windows \\ System32 \\ drivers \\ etc   put a file called hosts, but with the extension .txt   (hosts.txt file) or without an 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 lines at the end of the content
(Line skip)
127.0.0.1 (multiple spaces) (Name of the domain to be blocked)
127.0.0.1 (several spaces) (Name of the domain to be blocked with www.)

On the example of the same VKontakte and Odnoklassniki:



Save. We check our work by entering the URL of these sites in the address bar of the browser. Sites do not open. Bingo!

Thus, you can 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 at the entrance to 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/

To determine the IP addresses of any Internet sites full of services. Google.

hosts denied access - what to do

If you save the file, you cannot and access is denied. We do it in the order of the queue, trying to save the file after each item.
  1. Open in Notepad as administrator.
  2. Copy the file to the desktop. Change it. The hosts file remaining in the folder C: \\ Windows \\ System32 \\ drivers \\ etc   rename to hosts.old. Copy the hosts file edited on the desktop to the folder C: \\ Windows \\ System32 \\ drivers \\ etc.
  3. Turn off antivirus. Antiviruses often ensure that no changes are made to this file. Add file to Windows Defender exceptions. Starting at 8 windows versions   makes sure that no one changes this file.
  4. We set access rights to the file in its properties on the "Security" tab.
  5. If you can’t delete 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 are problems with connecting to the Internet. During the connection, the IP address 127.0.0.1 will have to be specified manually. Perhaps some programs will ask for the name localhost, rather than the address 127.0.0.1, which will create another problem.