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 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 – you can edit your hosts file to block ads.
Lewis Lambert Fox
Jul 06, 2021 · 4 min read
In this entry, we will take a look at how to block harmful websites, banners, and trackers, 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. Read on to learn how to block ads with hosts file.
First, what is your hosts file location, and how does it work? 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 edit 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.
It’s time to learn how to edit hosts files. Editing 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
Edit 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 edit 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.
Hosts file ad blocking is a relatively simple and effective way to protect yourself from annoying and malicious ads. Try it out today!
There are many other ways to protect yourself online, of course. For example, you might want to modify your browser's third party cookies settings, to prevent websites tracking you.
And if you want a simple all-in-one solution for your privacy and security needs, try NordVPN. This powerful encryption service comes with built-in malware protection, which can spot and neutralize the threat of malicious online ads.
Whether it's ransomeware, spyware, or some other virus, malicious software is everywhere online. Keep yourself secure with NordVPN.