The hosts file is a very important system file – you can edit it to change what happens when you try to visit certain domains, such as creating local redirects and blocking websites.
There are several ways to edit the hosts file on a Mac – one of them relies on the Terminal, although it’s not the quickest or easiest. A better solution enables you to edit the Hosts file from System Preferences on Mac.
How to edit the Hosts file from System Preferences on Mac
To do this, you will need a lightweight app called Hosts.prefpane which enables you to edit the hosts file from System Preferences. To begin with, download the latest version of the app from the link below then install it.
Once you install the app, go to System Preferences and click on the new “Hosts” icon that’s been added to the bottom of the window.
You’ll be taken to the new Hosts preferences pane. Administrative rights are required to edit the hosts file so begin by clicking the lock icon.
If you have Touch ID, your fingerprint will be required for authentication. If not, you’ll need to enter your password. Keep in mind the hosts file can only be edited by the system administrator, so you will need the proper credentials for this to work.
Now you can easily add and remove domains as needed using the “+” and “-” buttons. You just need to enter “127.0.0.1” for the IP and the domain you want to block.
The “use” column allows you to remove domains from the hosts file but still keep them in your list, in case you want to add them later. Whatever changes you make, they’ll be automatically applied to the hosts file. You can check them by opening the hosts file from /private/etc/.
You can also try opening a domain you’ve redirected directly in your browser to check the changes. Normally, it should work fine but if it doesn’t restart your browser and give it another try.