Hosts File For Mac



Hosts File For Mac

Jan 01, 2013 Editing the Hosts file is a way for overriding DNS settings, and can be very useful for web development, or blocking a harmful domain. On Mac OS X, the Hosts file is used in much the same way as other operating systems. The difference is file location, and method of editing. Mar 21, 2019 Hosts file is a hidden gem on your Mac that lets you override DNS settings exactly as specified. Let’s elaborate. Any website on the internet has a standard numeric TCP/IP address (e.g. 155.135.55.81) — that’s how your browser is actually able to find the website you want. Learn how to edit hosts file in Mac OS. Don't forget to check out our site for more free how-to videos!

Active computer users are probably already familiar with the Hosts file that contains network information. Through this file you can block access from your computer to a particular website, or make other changes to the access of your computer to a certain IP address. Despite the fact that Mac Os is a system that is pretty much closed from user interference, it has a file named Hosts that can be edited. At the same time, editing here is not at all more difficult than on Windows, and within the framework of this article we will tell you how to do this.

How to open and edit hosts via “terminal”

The easiest way to access Host file editing is to use a command line, which in Mac OS is called “Terminal”. You can run “Terminal” utility through the Finder, it is located in the list of standard programs of the operating system, or you can just use a search and type its name.

“Terminal” is running and now you need tostart editing the Host file. To do so you will need to enter and execute the following command:

After activating this command, you will also need to enter the administrator’s password for the computer, because intervention in Hosts file is quite serious, and if this file is edited incorrectly, you may experience problems accessing certain websites on the Internet.

After entering the right password, you will be able to see the Host file contents that can be edited by a user. When editing the file through “Terminal” your mouse will not work, so you will have to move between the lines of this file only with the help of your keyboard. Enter the changes you would like to make in the Hosts file. To save all changes in this file, you will need to press Ctrl + X on your keyboard. Next you are going to see a message asking you to confirm whether you want to change Hosts or no, confirm the action with “Y” button.

How to open and edit hosts via finder

The second way to access Hosts and edit the file involves using the standard Finder. This way, you can open the Hosts file and edit it in any text editor, so this option may be preferable in a number of cases.

To open Hosts through the Finder you need to right-click on the lower menu on the Finder and select “Go to Folder”.

Then there will open a window and in this window you need to enter a path to the folder you want to go to. Enter the following address:

And click “Go.”

There will open a system folder in which the Hosts file is located. To start editing it, you need to right-click on it and select the editor that you would prefer to work with (you can use the standard TextEdit).

In the window that opens, you can edit the Hosts file just like any other file in a text editor. But the Hosts system file is protected from editing. After you try to make changes to it, you will see a message with suggestion to create a duplicated file. Click “Duplicate”. After that the second file will form on the basis of the first one.

Next, you will need to make all necessary changes to the new created file and save it in a convenient place, for example, on the desktop. When saving, select the .txt resolution (same resolution that the original Hosts file has). Now your new file is saved and you will need to just replace the old file in the system folder. To do this, drag the new file to the folder where the old Hosts is located and click “Replace” when the corresponding message appears. As a result of these actions, the old Hosts file will be deleted, and the new one will be used by the system instead.

How to apply hosts file changes

Some changes that are made in the Hosts file are not perceived by the system at once and, accordingly, do not work. For the changes to take effect, you need to update the DNS cache. This can be done using the terminal with the command:

After executing this command, the Hosts file will be read by the system again, and all the changes that were made to it will be reflected on the computer’s operation.

File

Fixing hosts file on Mac will help to intervene in the system, help block websites or block browser ads.

File hosts on the system help users to intervene deeply into the computer, support users to change the system such as blocking ads from certain websites or software such as blocking ads on Viber, or blocking websites. browser, even support access to blocked websites, .

File hosts on all operating systems allow users to change, edit, add commands to meet the purpose we want to perform. To edit the hosts file on Mac, users also need to follow each step in the order as when editing the hosts file on Windows 10 or changing the hosts file on Linux. The following article will guide readers to change the hosts file on a Mac.

  1. 5 ways to block websites and limit usage time on Linux computers
  2. How to open the hosts file on Windows
  3. How to reset HOSTS files on Windows 7/8 / 8.1 and Windows 10
  4. How to create a new host file on Windows

Instructions to edit the hosts file for Mac

Method 1: Edit the hosts file on Mac via etc

Step 1:

First we press the key combination Command + Shift + G to display the directory access dialog. Next we enter / etc into the search field and click Go to continue.

Step 2:

Show etc folder with many files inside. Users browse to fie hosts and then double click to open and edit and save.

In case the hosts file does not save, we overwrite the content, the user moved that hosts file to the desktop or another directory to edit. Then copy to the etc directory to overwrite the existing hosts file.

Method 2: Edit the hosts file on the Mac via Terminal

For Mac OS, we have more ways to fix hosts file via Terminal.

Hosts File For Mac Os

Step 1:

Users access to Utilities folder and then click on Terminal in the list to launch. Or we press the keyboard shortcut Commnd + Space and then type the keyword Terminal to open up.

Hosts File For Mac

Step 2:

Hosts File Mac Os X

In the interface shown, enter the command sudo nano / private / etc / hosts and then type the password of the Mac into the Password line below. Click Return to open the hosts file.

Step 3:

Hosts File Mac Not Working

Display the hosts file interface for users to edit. We use the left and right up and down arrows to move the cursor to where the content of the hosts file needs to be edited.

Where Is The Host File

Step 3:

Once finished editing, we press Ctrl + X and then press Y to agree to save new content to the hosts file. Finally press Return to agree or press N to not save the content.

So we have 2 different ways to edit the hosts file, change the content of the hosts file on the Mac. If you edit the hosts file via etc, it is best to copy the file to another location for editing and then copy the etc folder again to overwrite the existing file.

I wish you successful implementation!

READ NEXT»