Home » Blog » Mac OS X » How to Block Unblock Website on Mac Terminal?

How to Block Unblock Website on Mac Terminal?

Jamie Kaler   Contribution
Rollins Duke
Rollins Duke  Approved By
Published On April 8th, 2024 • 5 min read

You will understand how to block or unblock website on Mac terminal in this section. You may go one step higher by simply preventing your computer from visiting some websites altogether. The majority of online browsers are equipped with plugins that can assist you in remaining productive and preventing you from opening websites on which you are spending time.

There are a variety of methods available for blocking websites on a Mac, including the built-in function of Parental Control, third-party applications that are specifically designed to block websites and applications, and altering the host’s files on your Mac. However, the use of Terminal is by far the simplest method for blocking websites on a Mac.

One can want to block a website for different reasons. It may be attempting to deliver you malware or unwanted messages. Or if youngsters use the PC then you may block some pornographic material or ultra-violent media to guarantee that they are not harmed by it when simply skimming over the internet. While no form of the material may be prevented 100 per cent you can always the key websites and attempt to control the use of your PC.

Therefore, in this section, we will demonstrate the most effective method for blocking websites on a Mac by utilizing Terminal.

Why Block Unblock Website on Mac?

There are numerous reasons for blocking and unblocking websites on macOS, as per the user’s need. To avoid any viruses or unsolicited warnings, or prevent any of the offensive content from the minors. Although total avoidance won’t constantly achieve success, limiting get right of entry to crucial websites can aid in efficient computer utilization management. Users can manipulate their online surroundings on a Mac gadget in reality and correctly using the usage of Terminal technique described in this section. Users have greater manage over their digital enjoy whilst they can block or unblock websites for protection, productiveness, or parental advice.

How to Block Websites on Mac using a Terminal?

To block or unblock a website on the Mac terminal process, admin login details are most important. All the steps are given below:

  1. Open the terminal on your Mac system.
  2. Now enter the command to open the host’s file:
    sudo nano /etc/hosts

    block unblock website on mac

  3. Here you have to enter the login details of the admin account.

    enter the login details

  4. Find the line “ Localhost” in the editor.

    Find the line

  5. Now type this command: <TAB> <website url>
    Example:  www.facebook.com

    type this command

  6. Now press CTRL + O to save the changes and return from the terminal.

    save the changes

Now open your browser and search the blocked website to recheck whether that site is blocked or not.

Now you can see the whole process of blocking websites on Mac using the terminal. After that, we will show you how to unblock websites on Mac using the terminal. The complete procedure is mentioned below:

How to Unblock Websites on Mac Terminal?

  1. Firstly, Open the terminal on your Mac system.
  2. Now type the command to open the host file:
    sudo nano /etc/hosts
  3. The screen will open and enter the admin login details here.
  4. Now find the blocked websites here.
  5. After that, use the # icon in front of blocked sites, as you can see below:

    unblock website on mac terminal

  6. Lastly, hit the CONTROL + O to save the changes and then open the website on your web browser.

Time to Say Goodbye

Finally, as you may notice from the instructions that were provided above block unblock websites on Mac terminal is an easy process that takes little time. Above, you get the complete and detailed knowledge to block or unblock the websites.


Q) Why is it necessary to block any website on macOS?

A) Block website On Mac, blocking websites can shield the system from viruses or unsolicited communications.

Q) Does the Mac have integrated functionality for blocking off websites?

A) Yes, Parental Controls on Macs can be used to restrict get right of entry to to specific websites. However, users regularly turn to using tools like the Terminal to restrict or unblock websites to have more freedom and manage.

Q) Is it hard to block or unblock website on Mac using Terminal?

A) No, with a terminal we can easily block and unblock the websites. All you need is administration and a basic understanding of using the terminal.

Q) What happens if I subsequently want to unblock a website?

A) unblocking a website on a Mac is also quite easy by using the mentioned Terminal approach. You can get back access to the website by modifying the host file and deleting the block for that particular website.

Q) Is it possible to temporarily blog websites or set a time limit?

A) You can set a time limitation for visiting the website or schedule the website blocks for a particular time with a third-party application but with the terminal method you can only blog permanently unless you update it manually.