How to Unblock Website on Mac Terminal?

admin | how to Mac macOS | 5 minutes read | Modified on: 06-08-2026

Sometimes when using the internet, it is necessary to change your local settings and limit or allow access to some web pages. Maybe you once limited access to some website to reduce possible distractions at work time, limited it for parental reasons or have got a computer with custom network settings; whatever the reason is, it might be frustrating for you not to have access to some particular website.

MacOS provides plenty of graphical interface solutions and third-party software for manipulating network packets. But one of the easiest, lightest and straightforward methods to do that is through the Terminal utility. It comes together with the operating system. By changing your local routing settings, namely hosts file, you will easily regain access to all restricted domains in a few minutes.

In this article, we will consider what techniques are commonly used to block websites locally on the macOS computer. It will cover how to safely access and manipulate your system configuration files in the command-line utility, and how to reset your network cache.

Understanding How Websites Are Locally Blocked

Sometimes when using the internet, it is necessary to change your local settings and limit or allow access to some web pages. Maybe you once limited access to some website to reduce possible distractions at work time, limited it for parental reasons or have got a computer with custom network settings; whatever the reason is, it might be frustrating for you not to have access to some particular website.

MacOS provides plenty of graphical interface solutions and third-party software for manipulating network packets. But one of the easiest, lightest and straightforward methods to do that is through the Terminal utility. It comes together with the operating system. By changing your local routing settings, namely hosts file, you will easily regain access to all restricted domains in a few minutes.

In this article, we will consider what techniques are commonly used to block websites locally on the macOS computer, how to safely access and manipulate your system configuration files in the command-line utility, and how to reset your network cache.

Step by Step Guide: How to Unblock a Site Using Terminal

Any modification done to the system files requires administrative rights. Below are the steps on how to modify your host file using the command line text editor, nano.

Step 1: Open the Terminal Program

The first step is to open the command line program from your Mac.

  • Click Command + Spacebar to open the spotlight search.
  • Type terminal and click return.
  • Optionally, open finder, go to applications > utilities and click on terminal.

Step 2: Opening the Hosts File with Administrative Privileges

In the terminal program, type the command “sudo” (Super User DO) followed by “nano”. The full command is as follows:

sudo nano /etc/hosts

Your Mac OS X will ask for the login password of your Mac for security purposes. While typing your password, not even asterisk symbols will be displayed on your screen, which is a normal security measure in macOS Terminal. Just type your password blindfolded and press return.

Step 3: Locate the Blocked Website Entry

Once authenticated, the Terminal interface will transform into the Nano text editor, displaying the contents of your /etc/hosts file. It will look similar to this:

Plaintext

##

# Host Database

#

# localhost is used to configure the loopback interface

# when the system is booting. Do not change this entry.

##

127.0.0.1               localhost

255.255.255.255 broadcasthost

::1                           localhost

127.0.0.1               www.restrictedwebsite.com

Use the arrow keys on your keyboard to scroll down the text lines until you locate the blocked website entry. This should normally appear in the form of 127.0.0.1 and then the website domain name.

Step 4: Remove or Comment Out the Line

Two choices to unblock the website are available to you:

  • Removing the line: You will need to put your cursor at the beginning of the line containing the website to be unblocked, then either press the Delete key or Backspace key to delete the entire line.
  • Commenting on the line: In case you would like to block the website again in the future, you can temporarily disable this blocking rule by adding the hash symbol (#) at the beginning of the line.

Step 5: Save and Exit the Editor

After you have changed or deleted the entry that you targeted, you will need to save your update:

  • Press Control + O (the letter ‘O’ and not zero) on your keyboard to have the file “Write Out” (saved).
  • Press Return afterward to accept the already existing file name (/etc/hosts).
  • The final step is the pressing of Control + X to quit the Nano text editor and come back to the standard Terminal prompt.

Clearing DNS Cache

Even after modifying the hosts file, your browser or operating system may still retain a memory of the old network rules via its internal cache. If you attempt to open the website immediately and find that it still fails to load, you must flush your Mac’s DNS cache.

Run the following command in your Terminal window and press Return:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

This command clears out any residual routing paths and tells macOS to reload its network configuration framework immediately.

Verifying Your Changes

Once the configuration is updated and caches are emptied, it’s time to put your efforts to the test:

  1. Open your favorite internet browser (e.g., Safari, Firefox, Chrome, etc.).
  2. Either erase your browser cache, or open a new incognito or private window to prevent cached information from showing up.
  3. Enter the URL of the website previously blocked.

Now the website should appear. If any problems persist, double-check the typing in the /etc/hosts file, or restart the system to reset the processes running in the back.

Troubleshooting Common Issues

The use of the Terminal is definitely very efficient, but there can be some minor syntax errors causing problems:

  • Permission Denied Errors: Make sure you used sudo before your command. Your local Mac account must have administrative privileges for you to make changes to the system.
  • Unintended Global Blocks: If you happen to delete important lines like 127.0.0.1 localhost, you may experience issues with the internal networking functionality of the computer.
  • Other Blocking Methods: Keep in mind that using the hosts file is limited to blocks that were made locally by IP redirection. If the website is blocked on the level of the external Wi-Fi router or firewall, changing the local hosts file on the Mac will not make any difference.

By knowing how local routing works and by using such simple command-line text editors as Nano, you will remain in charge of your network environment.