You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can't block websites using Terminal

Hey everyone, having some trouble with the below and wanted to see if anyone has solutions or ideas! Asked around, even in Reddit, without any luck so far:


PROBLEM:

Can’t block websites for productivity via hosts in Terminal on personal computer. Don't want to use Screen Time because it's easy to workaround.


It worked successfully on my work computer, so know it's possible. However, no luck on my personal computer. They’re the same Mac models and I’m using the same WiFi router for both.


MAC DETAILS:

MacBook Pro, 2023 with Ventura 13.4.


SO FAR:

I’ve followed all of the below instruction and, again, it worked on my work computer, but not personal one:


  1. Type in the command below and press Return on your keyboard. This will open the hosts file: sudo nano -e /etc/hosts
  2. Use the arrow keys to go to the bottom of the line. Type 127.0.0.1 and the website address you want to block. For example, to block YouTube, I would enter the following in Terminal: 127.0.0.1 www.instagram.com
  3. Type each website on a separate line. Once you’re done, press Control + O followed by Return on your keyboard to save the file, and then Control + X to close the file.
  4. Type the following command to flush the cache, which will enforce these changes across the browsers. Press Return to enter the command: sudo dscacheutil -flushcach (I've also tried: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder)


Full instructions found here.


TROUBLESHOOTING ATTEMPTS:

  • Tried different variations of the URLs:
  • with/without www.
    • with/without https://
  • Tried using 0.0.0.0
  • Tried using with and without a tab after the numbers
  • Cleared caches (Safari & deleted caches out of Finder folder), restarted, etc.

While these forum posts are older, I tried them without luck:


Forum 1

Forum 2


Here's what I'm seeing on my end for a quick example:




Any help will be much appreciated and hope it helps others in the same boat... thank you!

MacBook Pro 14″, macOS 13.4

Posted on Jun 20, 2023 2:27 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 18, 2023 5:54 PM

Do you have VPN or Private Relay on? I had the same issue and found out that Private Relay was bypassing it - I turned off private relay and works like a charm.....now if someone can figure out how to make both of them work!

Similar questions

19 replies

Can't block websites using Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.