SEOClerks

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:

C:WINDOWSSYSTEM32DRIVERSETC

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

/private/etc/hosts

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 winhelp2002.mvps.org

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 ad.doubleclick.net, i'll add this to my hosts file as shown below:

How to Block Ads with Hosts File

We use "0.0.0.0" as it doesn't resolve anywhere, this can increase page times, as having "127.0.0.1" will constantly want to load localhost. Also, if certain programs use 127.0.0.1 this can create issues, so make sure to use 0.0.0.0 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?

Comments

Please login or sign up to leave a comment

Join
Lynne
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?

Everett
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?

galegatling
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?

Akki12
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?

itommy
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?

Order Now
Process Time: 1.0239188671112

Possible Duplicate queries found!
MatchCountSQLScript
SELECT * FROM `questions` as q JOIN categories_faq as c ON q.catid=c.CATID WHERE (q.status=1 OR (q.status=2 AND userid='') ) AND q.quesid='17666'1SELECT q.*, c.seo as CatSEO, c.name as CatName, c.parentid FROM `questions` as q JOIN categories_faq as c ON q.catid=c.CATID WHERE (q.status=1 OR (q.status=2 AND userid='') ) AND q.quesid='17666'

/opt/clerks-staging/docroot/viewfaq.php 496 () ()

SELECT * FROM seoclerks.members WHERE USERID='2951'1SELECT * FROM seoclerks.members WHERE USERID='2951'

/opt/clerks-staging/docroot/include/functions/includes/member.php 445 GetAllUserDetails() ()

SELECT * FROM seoclerks.members WHERE USERID=29511SELECT googleplus_profile FROM seoclerks.members WHERE USERID=2951

/opt/clerks-staging/docroot/include/functions/main.php 16914 GetGooglePlusProfileFromId() ()

SELECT * FROM ratings_faq as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=17666 LIMIT 51SELECT m.username FROM ratings_faq as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=17666 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM answers a, seoclerks.members b WHERE a.quesid='17666' AND a.userid=b.USERID and b.status='1' AND a.status=1 ORDER BY a.combined_votes DESC, a.date_answered asc1SELECT a.answer, a.USERID, a.upvotes, a.downvotes, a.ansid, a.parentid, a.combined_votes, a.date_answered, b.username, b.userlevel, b.profilepicture FROM answers a, seoclerks.members b WHERE a.quesid='17666' AND a.userid=b.USERID and b.status='1' AND a.status=1 ORDER BY a.combined_votes DESC, a.date_answered asc

/opt/clerks-staging/docroot/viewfaq.php 1245 () ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=96529 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=96529 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=96547 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=96547 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=121006 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=121006 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=186959 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=186959 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

SELECT * FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=137108 LIMIT 51SELECT m.username FROM ratings_faqanswers as r, seoclerks.members as m WHERE r.USERID=m.USERID AND r.upvote=1 AND r.PID=137108 LIMIT 5

/opt/clerks-staging/docroot/include/functions/main.php 17159 GetVoters() ()

UPDATE questions SET total_views = total_views + 1 WHERE quesid='17666'1UPDATE questions SET total_views = total_views + 1 WHERE quesid='17666'

/opt/clerks-staging/docroot/include/functions/main.php 1765 update_Faqviewcount() ()

SELECT * FROM questions WHERE quesid!='17666' AND status='1' AND (question like '%How Block Ads Hosts File%' OR question like '%Block%' OR question like '%Hosts%' OR question like '%File%') -- ORDER BY RAND() LIMIT 151SELECT quesid, question, seo, userid FROM questions WHERE quesid!='17666' AND status='1' AND (question like '%How Block Ads Hosts File%' OR question like '%Block%' OR question like '%Hosts%' OR question like '%File%') -- ORDER BY RAND() LIMIT 15

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() ()

SELECT * FROM seoclerks.members WHERE USERID='840' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='840' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='9399' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='9399' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='9' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='9' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='43' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='43' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM seoclerks.members WHERE USERID='17031' limit 11SELECT profilepicture FROM seoclerks.members WHERE USERID='17031' limit 1

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_member_profilepicture()

SELECT * FROM members_ledger WHERE script='/opt/clerks-staging/docroot/viewfaq.php' AND querystring LIKE '%id=17666%' AND added>=UNIX_TIMESTAMP(NOW())-1200 GROUP BY USERID 1SELECT USERID, username FROM members_ledger WHERE script='/opt/clerks-staging/docroot/viewfaq.php' AND querystring LIKE '%id=17666%' AND added>=UNIX_TIMESTAMP(NOW())-1200 GROUP BY USERID

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() ()

SELECT * FROM categories1SELECT * FROM categories

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() parseRedundantQueriesCache()

select * from categories_software order by name asc1select * from categories_software order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_GetSoftwareCategories()

select * from categories_wanttobuy order by name asc1select * from categories_wanttobuy order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_wantcategories()

select * from categories_wanttotrade order by name asc1select * from categories_wanttotrade order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_get_tradecategories()

SELECT * FROM seoclerks.members WHERE USERID='306632.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='306632.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='2951.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='2951.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='598592.jpg'1SELECT profilepicture FROM seoclerks.members WHERE USERID='598592.jpg'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

SELECT * FROM seoclerks.members WHERE USERID='275652.png'1SELECT profilepicture FROM seoclerks.members WHERE USERID='275652.png'

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() getUserProfileImage()

select * from categories_faq order by name asc1select * from categories_faq order by name asc

/opt/clerks-staging/docroot/libraries/adodb5/adodb.inc.php 1899 CacheExecute() insert_GetFaqCategories()

Invalid SQL

count(*)sql1error_msg

Expensive SQL

Tuning the following SQL could reduce the server load substantially
LoadCountSQLMaxMin

Suspicious SQL

The following SQL have high average execution times
Avg TimeCountSQLMaxMin
2.7553161SELECT A.*, C.username, C.profilepicture, C.userlevel, C.ratingcount, C.rating, C.lastlogin, C.ip, C.lip, C.profile_data from posts A, seoclerks.members C WHERE A.active=1 AND A.USERID=C.USERID AND A.sold_out=0 AND category IN (23,48,53,103) AND gtags like'%adscampaign%' AND type !=99 AND A.feat=0 AND A.catfeatured_upgrade=0 order by A.lastgigedit desc limit 0, 402.7553162.755316
0.4513211SELECT A.*, C.username, C.profilepicture, C.userlevel, C.ratingcount, C.rating, C.lastlogin, C.ip, C.lip, C.profile_data from posts A, seoclerks.members C WHERE A.active=1 AND A.USERID=C.USERID AND A.sold_out=0 AND category IN (62) AND gtags like'%WordpressSEO%' AND type !=99 AND A.feat=0 AND A.catfeatured_upgrade=0 order by A.lastgigedit desc limit 0, 400.4513210.451321
0.1070281SELECT A.wantid, A.title, A.p1, A.maxprice, B.name, B.seo FROM wanttobuy A, categories_wanttobuy B WHERE A.wantid != 60158 AND A.category=B.CATID AND A.active=1 AND (A.tags like '%Article Articlesreview Articlewriting Wikipedia Wiki%' ) LIMIT 40.1070280.107028