With the internet full of flashy pop-ups, scams and malicious traps, security-concerned internet users look for ways to protect their privacy and stay safe online. Most of the time, a combination of common sense and reliable security tools, such as browser add-ons or a VPN with malware protection, can help you to block annoying ads and malware-hosting sites. However, if you need additional protection or simply are looking for alternatives, here’s one – the hosts file. You don’t need to look far – it’s right here, on your device.
In this entry, we will take a look on how to block harmful websites, banners, trackers, etc., by editing your computer’s hosts file. Not only does this method keep you safe from various cyber parasites and junk, it also makes pages that you visit load faster and saves you some precious bandwidth.
The hosts file is a plain text file (hosts.txt) that translates websites’ hostnames into numeric IP addresses, before DNS (the Domain Name System). So when you enter a name of a website into your browser, the hosts file tries to resolve it first and only if the attempt is not successful, the request is sent to a DNS server. When the request is resolved by the hosts file, it doesn’t have to leave your device.
What’s handy about this method is that you can edit your hosts file yourself to specify the websites you want to be blocked or accessed through a particular IP address. Unlike in ad-blockers, changes that are made in the hosts file are applied not only on a particular browser, but across the entire OS,. So if you choose to block a website, you won’t be able to access it until you unblock it.
Depending on your security preferences, you can modify entries in your hosts file to block ad servers, third party cookies, banners and websites that are known for hosting malware or spyware. This also makes a great alternative to parental control software as you can block adult sites you don’t want your kids to visit.
Modifying your hosts file to block certain websites or pop-up windows from being shown on your browser is actually very simple, even if you are a complete technology newbie. The hosts file already resides on your OS, so you only need to make some changes in it. There are two ways of doing that:
The good thing about public blocklists is that they are regularly updated, so you don’t need to do that yourself. On the other hand, these lists sometimes may block websites that you consider legitimate and would like to access. So it’s up to you which method to choose.
To block a website from being shown on your browser, open and edit the hosts file. The location of the file depends on which operating system you are using:
Edit the hosts file on Windows
Modify the hosts file on Linux
Manage the hosts file on MacOS
If by any chance you’ve changed your mind and want to unblock any restricted websites, you are always welcome to modify your hosts file again. Simply select and delete the address you need to access or the whole list. Save your changes and restart the browser. The website you wish to access is available again.
Did you find these tips useful? Let us know in the comments below.