Block a Website in Safari

Do you want to block your kids from accessing certain sites, or keep your employees on task? You can use the terminal in OS X to block sites from loading in Safari on your computer, and you can use Restrictions to block sites on any iOS device. You can have sites blocked in just a few minutes.

Steps

Using your Mac

  1. Open the Terminal. To block specific websites, you will need to edit your "hosts" file. This file determines what can and cannot be accessed by the computer's network adapter. Adding websites to this file will prevent them from loading in any browser, including Safari.
  2. Open the hosts file. Type sudo pico /etc/hosts and press Enter. You will be asked to enter in the Administrator password. The hosts file will open in the Terminal's text editing program.
  3. Scroll to the bottom of the file. Use your arrow keys to navigate. Create a new line by pressing Enter.
  4. Type in the sites you want to block. For every site you want to block, enter 127.0.0.1 example.com and press Enter. Each entry should be on its own line.
  5. Save and exit the editor. Once you have entered all of the sites that you want to block, save and exit by pressing Ctrl + O and then press Enter.
  6. Flush your DNS. In order for the settings to take effect, you will need to flush your cash. You can do this by typing sudo dscacheutil -flushcache and pressing Enter. For more details on flushing the DNS, see Flush-DNS.[1]

Using your iOS Device

  1. Open the Settings app. You can set your iPhone or iPad to block specific websites, which will keep them from being accessed by any browser you have installed, including Safari.
  2. Tap "General". At the top of your General settings list, tap "Restrictions".
  3. Tap "Enable Restrictions". If you haven't enabled restrictions before, you will need to create a passcode to lock them.
  4. Tap "Websites". In the Restrictions menu, tap the "Websites" option to access the blocking tools. You can choose to limit access to Adult Content, but to block specific sites tap "Add a Website" in the "Never Allow" section.
  5. Enter in the website that you want to block. Type in the website address and press the Done button. If the website has a mobile site, you will need to add both. For example, to block Facebook you would need to block "www.facebook.com" and "m.facebook.com".
    • To block for complex URLs, you may need to visit them first and then copy and paste the address into the Restrictions tool.
  6. Test the block. Once you've set the block, try accessing the site. You should receive a message that the site has been restricted. If you can still access it, make sure that the URL was entered correctly. Copy and paste it if necessary.[2]

Related Articles

Sources and Citations