# Using the hosts file to stop people from reading some websites

**URL:** <https://boards.straightdope.com/t/using-the-hosts-file-to-stop-people-from-reading-some-websites/428850>\
**Category:** Factual Questions\
**Created:** [December 4, 2007, 10:53pm UTC](https://boards.straightdope.com/t/using-the-hosts-file-to-stop-people-from-reading-some-websites/428850 "2007-12-04T22:53:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [December 4, 2007, 10:53pm UTC](https://boards.straightdope.com/t/using-the-hosts-file-to-stop-people-from-reading-some-websites/428850/1 "2007-12-04T22:53:42Z")

</div>

Say I want to block someone who is not computer-savvy from reading some websites.

Could I just use the hosts file, and add, say  
127.0.0.1 [yahoo.com](http://yahoo.com)

Would this work?

Based on the other entries in my hosts file, it seems like this should work, but I tried it and it does not work. I can still go to [yahoo.com](http://yahoo.com)

What would be the proper syntax for this to work?

I even tried  
64.236.16.20 [yahoo.com](http://yahoo.com)  
to test re-directing [yahoo.com](http://yahoo.com) to [cnn.com](http://cnn.com)

Do I need to restart my computer for this to work?

---

<div class="post-metadata">

**Author:** ![MrSquishy](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@MrSquishy](https://boards.straightdope.com/u/MrSquishy)\
**Post date:** [December 4, 2007, 11:05pm UTC](https://boards.straightdope.com/t/using-the-hosts-file-to-stop-people-from-reading-some-websites/428850/2 "2007-12-04T23:05:25Z")

</div>

I believe the host name has to match exactly, so you might try [www.yahoo.com](http://www.yahoo.com) if that’s what you’re typing into your browser. I don’t think the hosts file on Windows allows wildcards either, although I stand to be corrected.

Oh, and it’s possible that you need to flush your DNS cache for it to work. I can’t remember in what order things get checked (i.e. if it’s hosts file, then cache, or cache then hosts file). Open a command prompt and type “ipconfig /flushdns” to clear the cache.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [December 5, 2007, 10:09am UTC](https://boards.straightdope.com/t/using-the-hosts-file-to-stop-people-from-reading-some-websites/428850/3 "2007-12-05T10:09:29Z")

</div>

**MrSquishy** nails it in one.

The name must match exactly with no wildcarding. So that means you need separate entries for [www.yahoo.com](http://www.yahoo.com), [mail.yahoo.com](http://mail.yahoo.com) and all the other [whatever.yahoo.com](http://whatever.yahoo.com) s.

Saving the HOSTS file triggers a DNS cache flush, so the “ipconfig /flushdns” step is not necessary. Can’t hurt though.
