HomeMac & iOSBlocking Outgoing Connections on Mac

Blocking Outgoing Connections on Mac

If you want to block ad trackers (including amazon, google, etc.), and (suspicious) connection to unwanted websites or block ad trackers, here are some steps (may vary slightly depending on the version of your macOS) to block connections:

  1. Open your terminal (CMD+S and type terminal on search)
  2. Back-up your current hosts file to Documents (or any) folder (in case of later restoration needed): Type in sudo cp /private/etc/hosts ~/Documents/hosts-backup
  3. Edit the host file: type in sudo nano /private/etc/hosts and press enter and it will ask for the admin password, typ and hit enter
  4. Use down arrow key and position the cursor below the default set of rules
  5. Type the IP address of the website you want to block connection with like so 0.0.0.0 domainname.com (if you want to block several connections, type each entry on a separate line) — for example "127.0.0.0 www.example.com example"
  6. close and open up terminal again, type in dscacheutil -flushcache to reset the cache and apply the new rules.

There are large list of host files available on github and other places, google and use those hosts file if you want to avoid ad trackers and other virtual garbages. Blocking some ad blockers crash some websites and some functionality of the websites may not work, so use it with what you will.

Here is one such a good host file: https://gist.github.com/consti/8022703

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Must Read