macYou may be wondering Where is the “Hosts” File on a MAC? The host file is located in the /private/etc/hosts on your MAC. Because it is situated in a protected area of the system, you cannot directly open the file and edit it. The solution is to copy the file to an unprotected location for example desktop and then make the modifications. The easiest way to find the host file is to use the Finder tool. When you have launched the Finder tool, you can select Go to Folder and enter the  file location /private/etc/hosts. Now, you must select the “hosts” file with your mouse cursor and drag it to the desktop. Doing so will unlock the file and enable you to edit it.

Editing the Hosts File on a MAC

To edit the host file, you must first open it by double clicking it. You will notice that it is a simple file that contains just a few lines of text and characters such as pound and hash tags. The file also list the IP address of the localhost and broadcasthost. Before making changes on the hosts file, you should first backup the files. The hosts file can be backup by entering the hosts backup command in the terminal app. When making edits in the file, you cannot use mouse click as the mouse has been disabled in the text editor. Instead, you are to use the arrow keys to travel to different lines.

Blocking Access to Certain Websites with the Hosts File

For some people, they edit the host file in order to block the user from accessing a certain site on the Mac system. If you want to block access to a specific website, you must map the particular website you want to block to an invalid IP address such as so that the browser won’t be able to display the page when someone tries to enter the URL.

Enter the Redirected URLs into the Hosts File

If you don’t want to redirect the website to an invalid IP address, you can enter the valid IP address of the site where you want the user to be redirected. In this way, the user will be redirected to a different site when he attempts to visit the site with the browser. You can find out the IP address of a website by sending a ping to the site via the Terminal. You must quickly record down the returned IP address on a text editor so that you won’t enter the wrong number into the file.

The entry should be entered in the format of the IP address followed by a space and then domain name. There is no limit as to how many entries of IP addresses you can enter into the host file. Every line should have only one entry. It is advised that you don’t delete the entries previously entered as they are required to be processed by the system when it is booting. As soon as you have entered a new entry, you should press Control + O key to confirm that you want the modifications on the file to be applied to the original version in /private/etc/hosts/.

Testing the Hosts File to See if it Works Properly

After you have finished making the modifications, you must copy and paste the hosts file back to the original location. There will be a prompt that ask you whether you want to replace the file. To authenticate the file replacement, you must enter your administrative password. After the file is replaced, you can enter the URL in your browser to see whether the changes have been effected. You may have to delete the existing DNS cache in order for the effect to take place. To delete the existing DNS cache, you can enter the syntax dscacheutil -flushcache into the terminal.


In conclusion, it is very easy to locate the hosts file and make edits to control the sites other users  will see.  You can try turning off your computer and restart the system again if the website did not display properly after you followed the steps above. Sometimes, you need to quit all open browsers in order for the changes to take effect.