How to Block Ads with Hosts File Tutorial

Write the reason you're deleting this FAQ

How to Block Ads with Hosts File

How to Block Ads with Hosts File
You may know how to block advertisements with an Adblocker browser extension, or addon. But did you know you can block ads with your system's host file? Before we get into blocking ads with a host file, lets focus on why you should block ads!

Benefits to blocking ads:

  • Advertisers won't be able to track your online activities, or habits
  • Faster page load times
  • Less of a chance in getting malware, adware, or even viruses/trojans
  • Cleaner websites
  • .. and many more benefits

Finding your hosts file

To start the process, you'll need to locate where your hosts file is stored.

For Windows XP to Windows 10, the host file is located in this path:


For Mac OS, the host file is located in this path:


Finding Connection Blocks

You can either add your own connection blocks, or use a list that was already generated. To save time, I would suggest using an automatically generated list, you can find these lists on your favorite search by searching keywords such as "hosts file ad block". Be aware that some sites that hosts these files actually remove hosts if they are paid by advertising companies to do so! Find a list that is untouched, such as

Blocking the Ads

It's quite simple to actually block connections. Here's an example of the hosts file:

How to Block Ads with Hosts File

To add a connection block you'll need the website domain, and that's basically it.

For instance, if I wanted to block, i'll add this to my hosts file as shown below:

How to Block Ads with Hosts File

We use "" as it doesn't resolve anywhere, this can increase page times, as having "" will constantly want to load localhost. Also, if certain programs use this can create issues, so make sure to use when adding connection blocks.

You don't have to block advertising websites, you can block any website connection. This method of blocking will also help you have a bandwidth limit, you can save your bandwidth, browse more and you don't have to pay your internet company more money!

If you have anything to add to this post, please post below! Give your thoughts on this blocking method. Do you use the hosts file to block ads?


Please login or sign up to leave a comment


Thanks for this info, it is a little too higher grade for me though! I'll pass it onto my sister, she understands this technical stuff when I don't!

Are you sure you want to delete this post?


This isn't that technical, it's pretty simple. All you're doing basically is adding websites into a file, and clicking the "Save" button in your text editor. There is already hosts files with the data already present, but I decided not to link to them. If you want to try this way of ad blocking, and don't know where to find the connection blocks I can always shoot over a PM to you. You can also use this with your Ad blocking extension, and/or addon as blocking ads with this method doesn't actually block or hide the HTML elements, so sometimes you have an odd looking website page view.

Are you sure you want to delete this post?


This is definitely working. I have been using this kind of method for quite some time now with my rooted android phone. I also used this to my sister's laptop because she keeps eating all the bandwidth watching random youtube videos and downloading apps.

Are you sure you want to delete this post?


Play the most fabulous games are this website if you are lover of online games play online euchre more user are like the online games then you are lover and continue the more time.

Are you sure you want to delete this post?


This is another way to block ad but I would not go with this way because it is complicated and easy to happen issues if we do wrong way. I would use addons or plugins which browsers providing.

Are you sure you want to delete this post?