Etc Hosts For Mac
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.
- Hosts 1.2 for Mac is free to download from our software library. This software for Mac OS X is a product of ee.clockwise. The application relates to System Tools. From the developer: Hosts is a system preference pane to manage your hosts file.
- Hostbuddy is the easiest way to manage and update the /etc/hosts file on your Mac. Add new entries and turn on and off existing ones with one click. It's perfect for switching between staging and production servers or just for testing out your new website before it goes live.
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.
Sudo nano /private/etc/hosts; Bear in mind that Terminal will not display any characters when you are entering the password. Simply type the password and press Return. The Terminal window will change. At the top, you will see the path of the hosts file, content, and control commands at the bottom of window. To open the hosts file use the command below (you can Copy and Paste it directly into the terminal window). Sudo nano /private/etc/hosts. Press the return key.Terminal will ask you for a password.Enter the Administrator password for your Mac. As you enter the password the characters will not appear on screen, this is a privacy feature included in Terminal, simply hit enter after you’ve. Ofcourse Hosts.prefpane will detect edits you made to the /etc/hosts directly and merge them into the listing. Backups of your hosts file is made in /Library/Application Support/Hosts.
“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.
How to open and edit the hosts file on Mac computers?
All Mac computers store a small, text based file called 'hosts'. Modifying this file is sometimes necessary to solve connection problems, set your own web server, and instruct the system to block access to specific websites (thus to prevent opening malicious websites). There are many reasons why you might need modify this particular file, however, access to it is not generally via the desktop folder. The most common way to make changes to the host file is using the Terminal application. This works on all Mac operating system versions, although the path sometimes varies.
In the new version of macOS, you can also modify the hosts file via Finder and the text editor. Making changes to the hosts file may seem daunting but with a proper guidance it is straightforward and useful to perform certain operations. Despite this, in some cases users are unable to differentiate between the DNS server and hosts file. To clarify, we will describe the differences and provide methods to modify the hosts file depending on your Mac operating system version.
Table of Contents:
It is recommended to run a free scan with Malwarebytes - a tool to detect malware and fix computer errors. You will need to purchase the full version to remove infections and eliminate computer errors. Free trial available.
What is the difference between DNS and hosts file?
Firstly, we will clarify the difference between Domain Name System (DNS) server and the hosts file. Inexperienced computer users commonly mistake the DNS server and hosts file to be the same. Therefore, modifications made to the hosts file that should be applied to the DNS server (and vice versa) lead to problems.
A DNS server is a database that responds to websites URL addresses expressed in more meaningful characters. These servers finds the correct IP address assigned to the particular URL address and allow you to access the desired website. They also create a hidden cache file where this information is stored, thus increasing loading speed when you try to access a website that you have previously visited.
The hosts file is one of the easiest ways to modify or deny DNS server entries. It can be useful to test a web server under development, so that you can access it through a URL address, rather than its IP address. Within the hosts file, you can associate a particular IP address and Domain name (i.e. URL address). The Mac will open the IP address assigned to a particular URL address within the hosts file, ignoring the DNS server results. This is also an effective way to block unwanted websites. For example, if you are setting-up a new company computer and wish to prevent employees from accessing unnecessary websites (such as Facebook, Twitter, etc.), you simply assign invalid or other preferred addresses to these website URL addresses. As a further example, you can assign the invalid IP address 0.0.0.0 and URL www.facebook.com within the Mac host file - the computer will attempt to connect to the invalid IP addresses when the Facebook URL is entered. You can also assign your company homepage IP address, rather than an invalid IP. More detailed information about how to prevent Mac from accessing unwanted websites can be found in this article.
If you do not know the full IP address of a specific website, you can use Terminal and the command ping. Launch terminal via Spotlight, press the keyboard shortcut of Command and Spacebar, and type in Terminal. Type in the ping command with the URL address and press return. Within the results, you will find the website IP address. The example of the ping command listed below is: ping www.pcrisk.com
Modify hosts file via Finder
Os X Hosts File
On modern versions of the Mac operating system, the hosts file might be accessible and modified in two separate ways. First, via Finder - by moving the file to your desktop or another unprotected are. Second, via the Terminal application. We begin with hosts file editing via Finder. Launch finder and click the Go option in the menu bar at top of your screen. Then select Go to Folder and type the following path and click Go:
- /private/etc/hosts
By default, the 'etc' folder is protected against modification. Therefore, copy the hosts file to an unprotected location, for example, the desktop. There you will be able to modify the copy of the hosts file. Simply double click on the file to open it via the TextEdit application (or any other application able to open and modify text-based files).
At the top of the opened file, you will find comments (denoted by the hash [#] symbol). Anything placed on the same line that starts with this symbol is ignored by the system. In this way, comments and descriptions can be added to the file. Below the comment lines are the default IP addresses for localhost and broadcasthost. There might be other data, which is added by various applications. Enter your additional information below all existing entries. A common reason to modify the hosts file might be to block an unwanted websites from loading on your computer. Once you have finished editing, you must replace the original hosts file with this newly created version. Therefore, repeat the above procedure and go to the 'etc' folder.
Click the Go option in the menu bar at the top of the screen, select Go to Folder and type in the following path: /private/etc/hosts Click Go. Move the modified file to replace the old one. The operating system will ask you to authenticate to make changes within the protected folder. Click authenticate. You will now be asked to choose the action you wish to perform. Click Replace. Finally, you must enter the administrators account password to confirm your action. If you have blocked websites that already have been visited by this computer, you will need to flush DNS cache - detailed information can be found in this article.
Modify hosts file using Terminal
Modifying the hosts file via Terminal can save time spent moving the hosts file in and out of the protected 'etc' folder. In this case, however, you must work with the keyboard, rather than mouse or touchpad/trackpad. Using Terminal saves time spent moving the hosts file because you will be editing the original hosts file with super user permissions. Therefore, you are advised to create a backup of the hosts file, especially if you do not have experience of these techniques. Launch Terminal using Spotlight. Press the keyboard shortcut of Command and Spacebar. Type in Terminal and press Return. Alternatively, visit the Utilities folder under Applications via Finder to launch this built-in command line application.
Once Terminal is launched, type following command and press Return:
- sudo cp /private/etc/hosts ~/Documents/hosts-backup
To restore the hosts file, use the following command and press Return to execute:
Md Viewer
- sudo cp ~/Documents/hosts-backup /private/etc/hosts
Type the following command to access the hosts file by using a Unix text editor called nano. Press Return to execute the command. You will be asked to enter the administrators password to confirm access to super user permissions.
- sudo nano /private/etc/hosts
Mac Os Etc Hosts
Bear in mind that Terminal will not display any characters when you are entering the password. Simply type the password and press Return. The Terminal window will change. At the top, you will see the path of the hosts file, content, and control commands at the bottom of window. To navigate while using nano, use your keyboard arrow keys. Leave all existing information unchanged and type your additional data below (adding your data before the existing information could result in the application failing).
Enter your data, each on a new line. Once you have finished editing the hosts file, press the keyboard shortcut of Control and O and then press Return to save changes within the existing file. Then press the shortcut of Control and X to exit the nano editor. For the changes to take effect, you will need to flush the DNS cache - detailed instructions can be found in this article.
/etc/hosts Mac Restart
Video Showing how to modify hosts file on Mac
