Default Hosts File For Mac

  1. Reset Hosts File Mac
  2. Mac Os Host File Location

Last updated on February 28th, 2018

This is the default location of hosts file in Mac OS X: /private/etc/hosts. And, here is the way to edit the file. Open terminal and type this command: sudo nano /private/etc/hosts. And it will ask your system password once you enter the password, you will see a screen like this. The Hosts file is used by the operating system to map human-friendly hostnames to numerical Internet Protocol (IP) addresses which identify and locate a host in an IP network. The hosts file is one of several system resources that address network nodes in a computer network and is a common part of an operating system's IP implementation.

The HOSTS file (C:WindowsSystem32driversetchosts), is a plain text file that is used in operating systems (Windows, Mac, Linux, etc.) to map hostnames to numerical IP Addresses. The hosts file can override DNS and redirect websites to different locations.

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. 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).

Sometimes users modify the hosts file in order to block unwanted sites or to reach specific sites faster (increase Internet Speed). In other cases the hosts file may be incorrectly modified (compromised) by a malicious program to prevent Internet access or to redirect users to malicious content (URLs).

For all these cases, there is the need to restore the hosts file to its default settings (values) in order to resolve Internet connectivity problems.

In this tutorial you can find instructions on how to check hosts file's integrity and how to reset host file to its default state.

How to Check and Restore HOSTS file's integrity.

Step 1. Check HOSTS's file integrity.

1. Open Windows Explorer and navigate to this location on your disk:

  • C:WindowsSystem32driversetc

2. Right click at hosts file and select Open.

3. From the list of programs select the Notepad and click OK.

4. If, when opening the hosts file, you see the screen below (Screenshot No1), that means that the hosts file is untouched and there is no need to modify or restore it to its default state.

[Screenshot No1. Default (Unmodified) hosts file]

5. In the case that the hosts file has been modified incorrectly by you or by a malicious program, then you should see additional entries at the end of the hosts file (Screenshot No2). In that case proceed to the next step and reset the hosts file to its original settings. *

*Note: If the hosts file has not modified by you, then after restoring it to its default values, perform a virus scan.

[Screenshot No2. Modified hosts file]

Step 2. Restore HOSTS file to Default.

You can restore/reset the hosts file to its default (original) settings, by using two methods:

Method 1. Automatically Reset HOSTS file with Host Mechanic Freeware utility.

Reset Hosts File Mac

Method 2. Manual Edit and Restore HOSTS file.

Mac Os Host File Location

Method 1. Automatically Reset HOSTS file with Host Mechanic Freeware utility.

1. Download ASKVG's Host Mechanic Freeware utility. (Source). *

* Note: Some security software might show that the Host Mechanic is unsafe, when you try to download or run this software. Please ignore the message, it's a false positive, since this tool tries to modify a system file. On the other hand, if you feel uncomfortable to run this file, then proceed to Method-2 below and restore manually the HOSTS file.


2. Extract the downloaded zipped file (

3. Run Host Mechanic application.

4. Click at Restore Default Host File button.

5. Close Host Mechanic and restart your computer.

Method 2. Manual Edit and Restore HOSTS file.
Default hosts file mac

To manual reset (restore) hosts file to its default values:

1. Navigate to C:WindowsSystem32driversetc folder.


2. Copy the hosts file to your desktop. To do that:

a. Right click at the hosts file and select Copy.
b. Then right click at an empty space on your desktop and select Paste.

3. Right click at the hosts file (on your desktop) and select Open.
4. From the list of programs select the Notepad and click OK.
5. Select the text below and press Ctrl + C (Copy).

6. Go to the open 'host – Notepad' window and erase anything on it. [press Ctrl + A and press Delete (Del)].

7. Then press Ctrl + V to paste the above – copied – text.

Default Hosts File For Mac

* The hosts file should look like this:

8. From the File menu, select Save and then close the 'host – Notepad' window.

9. Finally, copy the hosts file from your desktop and paste it back to 'C:WindowsSystem32driversetc' folder. *

10. Choose Copy and Replace when asked.

11. Restart your computer.

That's it! Let me know if this guide has helped you by leaving your comment about your experience. Please like and share this guide to help others.

If this article was useful for you, please consider supporting us by making a donation. Even $1 can a make a huge difference for us in our effort to continue to help others while keeping this site free:
If you want to stay constantly protected from malware threats, existing and future ones, we recommend that you install Malwarebytes Anti-Malware PRO by clicking below (we do earn a commision from sales generated from this link, but at no additional cost to you. We have experience with this software and we recommend it because it is helpful and useful):

Full household PC Protection - Protect up to 3 PCs with NEW Malwarebytes Anti-Malware Premium!

You 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.