Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Editing /etc/hosts works to easily block/unblock sites, but if you already have a browser open, it doesn't work until the browser cache is flushed.

Is there any simple way on OSX to block connections to certain hosts, preferably without 3rd party software? I imagine Little Snitch does what I need behind the scenes, if anyone understands how that works.

share|improve this question

migrated from May 11 '13 at 3:32

This question came from our site for professional and enthusiast programmers.

you specify without 3rd party software, but it would be criminal not to mention that Little Snitch does what you want brilliantly! And should be a standard install on every OSX machine connected to the internet! – Jarrod Roberson May 11 '13 at 3:43
@JarrodRoberson Love little snitch! I'm looking to develop a piece of software that can block sites on it's own, similar functionality, any idea how LS works under the hood?. – Alex Marchant May 11 '13 at 4:14
up vote 3 down vote accepted

There are 3 ways to do this on Mac OS X without requiring you to do a lot more.

  1. You have already mentioned the first way - using /etc/hosts.
  2. You have also ruled out using the second way - using browser plugins.
  3. The 3rd way is to use the "Parental Controls" feature under System Preferences.

There is a 4th way - if you are talking about writing code and implementing your own script or your own custom app.

If you are talking about "under the hood" level implementation - i.e. you want to implement a custom application of your own (similar to Little Snitch), then you should get yourself familiar with the concept of iptables (linux systems routinely use this to control access rights to specific hosts and ports).

In Mac OS (which essentially is FreeBSD under the hood), the equivalent is ipfw (IP Firewall) and for Mac OS 10.7 onwards, ipfw has been deprecated in favour of pf (Packet Filter).

Reference article which you can refer to:

share|improve this answer
Thanks for adding to your answer, that's what I was looking for. – Alex Marchant May 11 '13 at 7:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.