Where are windows hosts files

How to Lock, Manage, Edit Hosts File in Windows 10

The Hosts file in Windows 10/8/7, is used to map hostnames to IP addresses. This Hosts file is located deep down in the Windows folder. It is a plain text file, and the size of the original default Hosts file is around 824 bytes.

Hosts File in Windows 10

In this post, we will see its location and also how to manage, lock, or edit the Hosts file.

Host file location

The Hosts file in Windows is located at the following location:

Lock Hosts file to prevent hijacking

Imagine clicking on www.thewindowsclub.com and seeing a completely different website load in your browser. Malware can redirect Web addresses on your computer by altering your Hosts file. This is referred to as the Host File Hijack.

To prevent Host file hijacks, you may navigate to it, right-click on it, select Properties and make it a Read-only file. This will lock down your Hosts file and prevent anyone or any malware from writing to it.

Block website using the Hosts file

To block a website using the Hosts File, simply add the following entry:

Although I do not do it, many users like to manually add entries to it in order to block the opening of one or more particular websites. Others, like to download and use List from well-known sources like mvps.org, to add entries which block malware sites from opening.

Edit Hosts file

If you need to edit the Hosts file, navigate to the following folder location:

Here you will see the Hosts file. Right-click on it and select Notepad. Make the changes and Save.

But sometimes, even when you are logged on with administrative credentials, you may receive the following error message:

Access to C:\Windows\System32\drivers\etc\ hosts was denied

Cannot create the C:\Windows\System32\drivers\etc\hosts file. Make sure that the path and file name are correct.

In this case, type Notepad in Start search and right-click on the Notepad result. Select Run as administrator. Open the Hosts file, make the necessary changes, and then click Save.

HostsMan

While you can always manually manage or edit Hosts file manually, I would like to suggest that you use a third-party freeware tool like HostsMan to do it.

HostsMan is a feature-rich tool that lets you add, remove, edit entries in the Hosts file. It also lets you easily add third-party Hosts lists that help in blocking malware sites and lets you easily enable or disable the hosts file. It includes a built-in hosts file updater & a hosts editor. It lets you scan the hosts file for errors, duplicates, and possible hijacks – and also lets you create an Exclusion list. One more useful feature it offers is the Hosts file backup manager. Backup your Hosts file to a safe place and use it to restore it, should the need arise.

Hostman also lets you Flush DNS cache, open Hosts with a text editor, count the number of hosts, find duplicates, replace IP, scan hosts for malicious entries, rearrange hosts, manage DNS Client Service and more. In short, its the only Hosts Manager that you will even need. You can download it from its home page. SysMate Hosts File Manager is another tool that lets you do so.

Читайте также:  Mac os как сделать скриншот всей страницы safari

How to manually reset Hosts file back to default in Windows may also interest you.

If your browser has been hijacked, you might find this post on Browser Hijacking and Free Browser Hijacker Removal Tools helpful.

Date: December 23, 2018 Tags: Hosts, Security

Where is the Hosts File on Windows x64?

[A German translation of this article is available at faq-o-matic.net.]

The subtle differences between 32-bit and 64-bit Windows present so many intricacies and pitfalls that even Microsoft employees seem to have trouble getting it right. I just stumbled upon a KB article that describes how to reset the hosts file to its original state. The topic alone is funny enough – it is not as if the default hosts file contained great amounts of data. An entry for localhost (IPv4 and IPv6) is all you need, and on Windows 7 / Server 2008 R2 not even that. But anyhow, there seem to be enough people asking MS support for this or they would not have troubled with creating a package (ResetHOSTSFileBackToDefaults.MSI) that basically empties the hosts file.

Is Hosts 64-bit or 32-bit?

As always, I am more interested in what the package does, and Microsoft is kind enough to explain that in most “Fix it for me” articles. As you probably know, the hosts file was, is and probably will always be located in %systemroot%\system32\drivers\etc . Simple enough. But wait: 64-bit systems have two system32 directories: one for 64-bit processes and the other for 32-bit processes. Now, where would the hosts file be located – or are there even two (potentially different) files?

The answer is: no, the hosts file exists only once on x64 Windows. And it is right where it belongs, in the 64-bit system32 directory. But where is that directory located on disk? Is it the one natively called system32 , or is it SysWOW64 ?

Redirection Confusion

This is where confusion kicks in. Many people, including the person writing MS KB article 972034, see the number “64” in the name of the folder SysWOW64 and think: yes, that must be the 64-bit version of system32 . Nice thinking, but wrong. It is exactly the other way round. For compatibility reasons, the name of the system32 folder did not change in Windows x64, although on 64-bit platforms the folder does not contain 32-bit but 64-bit executables! That leaves the question of where to put the 32-bit files that 32-bit processes need – and also expect to find in system32 ? Obviously, the same DLL cannot be present twice in the same folder.

The requirement of two different system32 directories was solved by redirection. Actually there are two independent folders in any x64 installation: system32 and SysWOW64 . The latter is shown to 32-bit processes under the name system32 . 64-bit processes do not use SysWOW64 .

How to Get to and Edit the Hosts File

If you want to edit the hosts file, you first need to locate and open it – on Vista and newer with UAC enabled from an elevated process (with admin rights). The procedure is a little tedious. Here is how to do it with 64-bit Notepad:

  • Click on the Start button, type “notepad” and press CTRL+SHIFT+ENTER. Acknowledge the UAC dialog.
  • Type CTRL+O. Navigate to C:\Windows\System32\drivers\etc . Select “All Files” in the bottom right corner.
  • Now you see the hosts file. Select and open it. Make your changes and save it.

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. Navigating to “etc” from the root does not work (because System32 is redirected and Sysnative is not shown in directory listings).

  • %Windir%\System32\drivers\etc . This works because file system redirection is disabled for the “etc” directory and thus accessing the 64-bit System32 works from a 32-bit process.
  • %Windir%\Sysnative\drivers\etc . Sysnative is an alias that can only be used from 32-bit processes to access the 64-bit System32 directory.

How to Edit the HOSTS File in Windows

Customize your network settings in Windows 10, 8, or 7

The Windows HOSTS file functions like a local copy of a DNS server, so knowing how to edit it might come in handy if you want to make custom domain redirects, block websites, or remove malicious entries set by malware. That said, you might run into permission errors and other problems when you make changes to this file in some versions of Windows.

Читайте также:  Как обновиться до последней версии mac os

The instructions in this article apply to Windows XP, Windows 7, Windows 8, and Windows 10.

How to Edit the Windows HOSTS File

In Windows 7, 8, and 10, you can’t save edits to the HOSTS file unless you open it directly from Notepad or another text editor. To do so:

Open Notepad or another text editor like Notepad++.

In the text editor, select File > Open and open the HOST file location at C:\Windows\System32\drivers\etc\.

Select Text Documents (*txt) in the bottom-right of the Open window and change it to All Files.

This step is required because the HOSTS file doesn’t have the .TXT file extension.

When files appear in the folder, double click hosts to open it.

Edit the HOSTS file and save your changes.

What If I Can’t Save the HOSTS File?

In some versions of Windows, you don’t have permission to save directly to the \etc\ folder. If this is the case, you might see an error like this one when you try to save:

Instead, you must save the file elsewhere like the Documents or Desktop folder. After saving, go to that folder, copy the HOSTS file, and paste it directly into the location where the HOSTS file should be (C:\Windows\System32\drivers\etc\). You’ll be prompted with permission validation and will have to confirm overwriting the file.

If you still have trouble saving the modified HOSTS file, check the file’s attributes to see if it’s been marked read-only. Right-click the file and select Properties to see the attributes.

Another option is to open your text editor program as an administrator so that the permissions are already applied to the editor. Then, saving the HOSTS file over the original can be performed without having to verify your admin credentials.

If you still can’t save to the HOSTS file location, you probably don’t have the correct permissions to be editing files in that folder. You should be logged in under an account that has administrative rights over the HOSTS file, which you can check by right-clicking the file and going to the Security tab.

What Is the HOSTS File Used For?

The HOSTS file is the virtual equivalent of a phone company’s directory assistance. Where directory assistance matches a person’s name to a phone number, the HOSTS file maps domain names to IP addresses.

Entries in the HOSTS file override DNS entries maintained by the ISP. While this hierarchy might come in handy for regular use, like to block ads or certain malicious IP addresses, its functions also make this file a common target of malware.

By modifying it, malware can block access to antivirus updates or force you to a malicious website. Thus, it’s a good idea to check the HOSTS file periodically or at least know how to remove false entries.

A much easier way to block certain domains from your computer is to use a custom DNS service that supports content filtering or blocklists.

How to Edit Your Hosts File in Windows 10

What is a Hosts File?

The hosts file is a local plain text file that maps servers or hostnames to IP addresses. This file has been in use since the time of ARPANET. It was the original method to resolve hostnames to a specific IP address. The hosts file is usually the first process in the domain name resolution procedure. Here is an example of a hosts file entry.

We use the above code as an example since it almost always included in every hosts file. Another example would be similar to the following entry.

  • The first section denotes the IP address where a request will be redirected to.
  • The second section designates the location that we want to redirect a request from.
  • The third section specifies a comment for the entry.
  • Each entry is usually separated by a space or a tab.
Читайте также:  Как открыть старую панель управления windows 10

We would add the above entry to our hosts file to associate the hostname (or domain name)В liquidweb.comВ with the IP addressВ 67.225.187.61. To provide a working example, let’s move on to the next section.

Why is a Hosts File Useful?

Let’s say we have just completed a migration to a new server. In order to see how our domains will look and operate on our new server before we move our DNS settings, we cannot just type in one of our current domain names as it will resolve to the old server we are moving away from (since we never move our DNS A records from the old server until we are sure the new site is working as expected).

So, to see how our domain will look on the new server, (without having to change our DNS records) we can simply modify our local hosts file to point the domain to the new servers IP. If our domain is liquidweb.com and the old IP is 67.225.187.61 and our new IP will be 72.30.35.10, we can temporarily comment out the current liquidweb.com entry (using a ‘#‘ symbol) and add an alternate entry which points to the new servers IP.

If we added the above entry to our hosts file, every time we open liquidweb.com in our browser, we will now be redirected to the 72.30.35.10 IP.

Where is the Hosts File Located?

The location of the hosts file will differ by operating system. The typical locations are noted below.

  • Windows 10 — «C:\Windows\System32\drivers\etc\hosts»
  • LinuxВ -В «/etc/hosts»
  • Mac OSВ X -В «/private/etc/hosts»

What Does a Hosts File Contain?

A hosts file contains entries similar to the following information. Your entries may differ significantly.

How Do I Edit my Hosts File?

Our \etc\hosts file is only editable as a Windows administrator. В Here is a short video on how to edit a hosts file.

Here are the directions on how to modify your hosts file.

Step 1.
Click the Windows button and type Notepad in the search bar.

Step 2.
Right click on Notepad and then Run as Administrator.

Step 3.
You’ll be asked, “Do you want to allow this app to make changes to your device?”. Choose Yes.

Step 4.
In Notepad, choose File then Open.

Step 5.
Navigate to C:\Windows\System32\drivers\etc\hosts or click the address bar at the top and paste in the path and choose Enter.  If you don’t readily see the host file in the /etc directory then select All files from the File name: drop-down list, then click on the hosts file.

Step 6.
Add the appropriate IP and hostname at the end of your hosts’ file, select Save, and then close the file.

Step 7.
Finally, you will want to flush your DNS cache for your computer to recognize changes to the file. Click the Windows button and search command prompt.

Step 8.
Type the following command in the terminal and press Enter

Conclusion

Modifying a hosts file has many benefits which can significantly impact how you view your new domain or website. Using this method to view a site allows us to see how any new changes affect the layout and functionality of a domain.

Should you have any issues when modifying this file, our Support Teams are filled with experienced Linux technicians and talented system administrators who have an intimate knowledge of how to facilitate this modification. We are always available to answer any inquiries with issues related to this article, 24 hours a day, 7 days a week 365 days a year.

If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server, Managed Cloud Servers, or a Dedicated server owner and you are uncomfortable with performing any of the steps outlined above, we can be reached via phone at 800.580.4985, or via a chat or support ticket to assist you with this process.

Оцените статью