Home > News Tips

How to Restore Hosts File on Mac (to default)?

Updated on Tuesday, December 3, 2024

iBoysoft author Vain Rowe

Written by

Vain Rowe
Professional tech editor

Approved by

Jessica Shee

English Français Deutsch やまと Español Português

Mac hosts file is a plain text document the operating system uses to correlate domain names with specific IP addresses. Conventionally, instead of finding the IP address of a certain host or domain name, the operating system prefers to use the IP address specified in the hosts file directly.

However, some users wonder how to restore hosts file to default on Mac when they mistakenly edit the hosts files or run into the issue of the hosts file not working on Mac. Take it easy, this post from iBoysoft demonstrates how to perform that mission with a step-wise guideline. 

how to restore Mac hosts file

Why do you need to restore the hosts file on Mac?

Users can edit and add the host entry to the hosts file located in the /etc/hosts folder on Mac. However, the hosts file may go wrong sometimes for certain reasons. First, if you add too many entries to the Hosts file Mac, it will process them incorrectly, making some of the TCP/IP addresses respond to the same domain name.

Or, if you have deleted some essential information from the Hosts file on Mac, it would work improperly.

Facing this issue, restoring the hosts file to the default status on Mac is a nice option to make it functional one more time.

Thanks will be given if you'd like to share this post to let more people know about the reasons for reducing the Mac hosts file not working.

 

How to restore hosts file on Mac?

Restoring the hosts file to its original state is not as tough as you think, you can follow up on this step-wise tutorial to complete this mission with ease. Just keep reading!

Step 1: Enter the hosts file on Mac with the assistance of Mac Finder. Open Finder, click Go and choose Go to Folder from the pulldown menu.

Step 2: Enter the following path and click Enter. For an accurate file path, you're recommended to copy and paste this path to the Go to Folder box directly.

/private/etc/hosts

how to restore Mac hosts file

Step 3: Once you locate the hosts file, copy it to another place, such as Desktop or Documents. Because you do not have permission to edit the hosts file on Mac directly in the etc folder, you can only restore the hosts file by replacing the troublesome one.

how to restore Mac hosts file

Step 4: Open the hosts file you copied out in Step 3, copy and paste the following content to replace the content in the copied file, and then the copied hosts file will back to the default state.

how to restore Mac hosts file

## 
# Host Database 

# localhost is used to configure the loopback interface 
# when the system is booting.  Do not change this entry. 
## 
127.0.0.1 localhost 
255.255.255.255 broadcasthost 
::1             localhost

 Note: If you ensure what content in the hosts file is necessary for the applications installed on your machine, please keep them original below the default content.

Step 5: Replace the hosts file you end editing into the etc folder by copying and pasting. When you're asked whether you confirm your action, click Replace and enter the user account password to proceed.

how to restore Mac hosts file

Step 6: Restart your Mac to ensure the contents you modified take effect on the machine.

You can check if you restored the hosts file successfully to compare the hosts file on your machine with the one we provided above. If yes, share this post to help more people!

 

How to safeguard the hosts file on Mac?

It's recommended to protect the hosts file on your Mac in case some accidents happen like phishing software, malware, or spyware attacking your machine and stealing your info. Here are how to protect the hosts file on Mac:

Firstly, make sure that only the administrative user accounts have permission to modify the hosts file on Mac, which prevents changes from unauthorized user accounts or hackers.

Secondly, make a backup of the hosts file on your Mac regularly so you can restore the hosts file to default when any issue happens on it like corruption or wrong modification.

Finally, do not install apps coming from unstable or suspicious websites or developers, and leave no chance for the malware or virus to maliciously tamper with the hosts file.

Last words

It's never too much to emphasize the security and normal working of the hosts file on a Mac which matters when you visit the websites or so. When the hosts file misbehaves or gets corrupted, you still have a chance to restore it to the default content to get it normal by following the steps provided by this post.

Additionally, a backup of the hosts file is always necessary as it helps a lot in restoring the hosts file to default when the hosts file works improperly or gets corrupted. You can just paste and copy the hosts file to another drive and save it well for the ultimate backup.

You may also interested in: