PDF download Download Article
Prevent Safari from opening certain sites with this quick guide
PDF download Download Article

This wikiHow teaches you how to prevent Safari from accessing a specific site on both iPhone and Mac platforms. You can change this setting from within the Restrictions menu on an iPhone, but you'll need to edit the hosts file on Mac if you want to block a site on desktop.

Blocking Websites on Safari

On an iPhone, go to Settings > General > Restrictions. Enter your passcode and tap “Websites.” Then, tap “Limit Adult Content” and add the websites you want to block under “NEVER ALLOW.”

Method 1
Method 1 of 2:

On iPhone

PDF download Download Article
  1. Advertisement
  2. It's in the middle of the page.
  3. This is the code you set when you turned on Restrictions—not necessarily the same as your iPhone's regular passcode.
    • If you haven't yet turned on Restrictions, instead tap Enable Restrictions and then enter your preferred passcode twice.
  4. This area is about halfway down the page.
  5. It's near the top of the page. A blue checkmark will appear to this option's left, signifying that it is active.
  6. Do this in the "NEVER ALLOW" section (not the "ALWAYS ALLOW" section) near the bottom of the page.
  7. This should be the website you want to block; make sure you include all parts of the website's URL (e.g., "www.example.com" rather than "example.com").
  8. It's a blue button in the bottom-right corner of the keyboard. This will block your selected website in Safari.
  9. Advertisement
Method 2
Method 2 of 2:

On Desktop

PDF download Download Article
  1. This will search your Mac for the Terminal app.
  2. This will run a command to open the hosts file, which is a file on your Mac that controls the websites you can access in all web browsers—Safari included.
  3. This is the password you use to log into your Mac. You won't see the characters appear as you type, but they will be entered into Terminal nonetheless.
  4. This may take a few seconds. Once the file opens in a new window, you can proceed with editing it.
  5. Use the arrow key to navigate to the bottom of the file. Pressing Return will create a new line.
  6. This should leave a few spaces' worth of room between 127.0.0.1 and the next piece of text.
  7. This will typically consist of typing www., the website's name (e.g., Google), and .com, .net, or .org.
    • The line will look something like this: 127.0.0.1 www.facebook.com.
    • If you're blocking multiple websites, each URL must be on its own line.
  8. Once you have entered all of the sites that you want to block, save and exit by pressing Control+O and then pressing Return. To exit the hosts file, press Control+X.
  9. Flush your DNS. In order for the settings to take effect, you will need to flush your DNS cache. You can do this by typing sudo killall -HUP mDNSResponder;say DNS cache has been flushed and pressing Return.
  10. Advertisement

Community Q&A

Search
Add New Question
  • Question
    How can I block something on an iOS device?
    Community Answer
    Community Answer
    To block a website like Facebook from stealing your information do the following: Follow these instructions to the "website" screen, but THEN, go to the "Limit Adult Content" section. There will be an option that says "Never Allow This site". Type in Facebook.
  • Question
    At step 2 when I enter sudo nano /etc/hosts and press enter, I get a little symbol of a "key" which will not allow me to enter my administrator's password. Any suggestions to overcome this?
    Community Answer
    Community Answer
    When the key symbol appears, type the administrator's password and ignore the fact that what you type doesn't show up on the screen, then press enter. The password is just invisible on your screen for security reasons.
  • Question
    I found that the method mentioned in the article blocks all the websites I have added except Bing. How do I block Bing?
    Community Answer
    Community Answer
    I have found that with some websites you need to add multiple versions of the url to get the block to work, such as one line with the 3 w's before the url and another without it.
See more answers
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

Video

Tips

  • Blocking a website from the Restrictions menu will also block it in other browsers on your iOS device.
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement

Warnings

Advertisement

You Might Also Like

Advertisement

About This Article

Jack Lloyd
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Jack Lloyd. Jack Lloyd is a Technology Writer and Editor for wikiHow. He has over two years of experience writing and editing technology-related articles. He is technology enthusiast and an English teacher. This article has been viewed 645,880 times.
How helpful is this?
Co-authors: 24
Updated: May 5, 2025
Views: 645,880
Categories: Safari Browser
Article SummaryX

1. Open your iPhone's Settings.
2. Tap General.
3. Tap Restrictions and enter your passcode.
4. Tap Websites in the "ALLOWED CONTENT" section.
5. Tap Limit Adult Content.
6. Tap Add a Website in the "NEVER ALLOW" section.
7. Enter your website's URL.
8. Tap Done.

Did this summary help you?

Thanks to all authors for creating a page that has been read 645,880 times.

Is this article up to date?

Advertisement