Hosts file is a text file present inside your computer’s Windows 10 folder which can be used to block sites. Hosts File in Windows 10, Locate, Edit & Manage.
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
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 Hosts file
To block a website using the Hosts File, simply add the following entry:
127.0.0.1 blocksite.com
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:Known_hosts File Location Windows 10
Access to C:WindowsSystem32driversetc hosts was denied
Or
Cannot create the C:WindowsSystem32driversetchosts 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.
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.TIP: Download this tool to quickly find & fix Windows errors automatically
Related Posts:
On occasion you will need to edit the hosts file on your machine. Sometimes because of an attack or prank, and others so that you can simply and freely control access to websites and network traffic.
hosts files have been in use since ARPANET. They were used to resolve hosts names before DNS. hosts files would be massive documents used to aide the network name resolution.
Microsoft kept the hosts file alive in Windows networking which is why it varies very little whether used in Windows, macOS, or Linux. The syntax stays mostly the same across all platforms. Most hosts files will have several entries for loopback. We can use that for the basic example for the typical syntax.
The first part will be the location to redirect the address to, the second part will be the address that you will want to redirect, and the third part is the comment. They can be separated by a space, but for ease of reading are typically separated by one or two tabs.
127.0.0.1 localhosts #loopback
Now let’s look at accessing the hosts files in the different operating systems…Windows 8 or 8.1 or 10Host File Location Windows 10 Defaults
Unfortunately Windows 8 or 10 makes it annoying to open apps as administrator — but it’s not too difficult. Just search for Notepad, then right-click on Notepad in the search results list, and choose to run it as administrator. If you’re using Windows 10 this will be on the Start Menu.
If you’re using Windows 10, it’ll look more like this:
Once you’ve done so, open up the following file using the File -> Open feature.Hosts File Location Windows 8
c:windowssystem32driversetchosts
Then you can edit as normal.Windows 7
To access the hosts file in Windows 7 you can use the following command in the Run Line to open notepad and the file.
notepad c:windowssystem32driversetchosts
Once notepad is open you can edit the file. In this example we will block Facebook. To do this just enter in the following after the # mark.
0.0.0.0 www.facebook.com
Now that you have edited your Hosts file make sure to save it.
Now notice if we try to access Facebook in IE we can’t get to the page.
We also were not able to get to it in Google Chrome… (check notes at the end). Also for more info on editing your Hosts file, check out The Geek’s article on how to create a shortcut to quickly edit your Hosts file.Ubuntu
In Ubuntu 10.04 and most Linux distro’s you can edit the hosts file directly in the terminal. You can use your favorite editor or even open your favorite GUI text editor. For this example we will use VIM. Like Windows 7, Ubuntu’s hosts file is located in the /etc/ folder, though here it is in the root of the drive. In order to edit the file you will need to open it as root which is why we use sudo here.
Now that it is open we can edit it to redirect Facebook into nothing. You will notice that with Ubuntu there is also a section for IP6. For most needs you will only need to edit it the top section and ignore the IP6.
Now we can save the file and try to go to Facebook.com. Just like in windows we will see that we are now redirected to a site that does not exist.Hosts File Location In Windows 10macOS (Any Version)
In macOS, accessing the hosts file is very similar to Ubuntu. Begin in terminal and use your favorite editor, even is you wish to call a GUI text editor, it is easier to do so from terminal.
The file will look a bit more like Windows, only with a little less explanation. Again we are going to redirect Facebook.
This time it seems that 0.0.0.0 is a loopback and will direct you to the computers Apache test page.Notes
There are some things to note from this walkthrough that we did notice. When tested it, Chrome did not use the hosts file in any operating system but we were able to block Facebook in Chrome by adding www.facebook.com. Also, make sure to place and extra line after the last entry for the section.
This should get you started in understanding the Hosts file and how it can help protect your computer. You can use it to block sites that you don’t want a PC to be able to access. If you have more suggestions for any of the operating systems we coved, then leave a comment and let us know!READ NEXT
*› How to Use the chroot Command on Linux
*› How to Make iPhone Apps Always Ask for Location Access
*› Do You Need an Antivirus on a Mac?
*› How to Hide Twitter Replies
*› How to Install Apps Directly On Your Apple Watch