How do I refresh the hosts file on OS X?

Ever wanted to block certain hosts on your MAC and then simply clear DNS cache. It’s actually fairly easy. This brief tutorial is for OSX 10.9+.

1. Open your TERMINAL (Launchpad > Other > Terminal).

2. To edit your hosts file simply type in:

sudo vim /etc/hosts

3. Type “i” to insert or edit the hosts file.

4. Lets say we wanted to block ads from this particular domain: pubads.g.doubleclick.net. The format would go as follows:

0.0.0.0 pubads.g.doubleclick.net

You can also do this localized format as well:

127.0.0.1 pubads.g.doubleclick.net

5. Once you are happy with the changes click “esc” on your keyboard. Then :wq

That’s is, you have now edited your hosts file on your MAC.

6. We now need to flush the DNS. In your terminal type in:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Hopefully, this helps someone to block porn, social network, gambling and so on. If you don’t have a list, there is a great community that grabs information from adaway.org, mvps.org, malwaredomainlist.com, someonewhocares.org, yoyo.org, and potentially others to create their lists. Have a look by clicking this > hosts file that is updated.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *