How to restore default hosts file on Mac OS

Some applications modify the hosts file on your Mac when they install, and don’t always clean up after themselves when you remove them. Adobe Creative Cloud is a well-known example of this. Even after you’ve uninstalled the app, those extra lines can remain in the hosts file and potentially interfere with other apps trying to connect to their servers. This guide walks you through how to restore the hosts file on Mac back to its default state, safely and without any third-party tools.

What is the hosts file on Mac?

The hosts file is a plain text file that your Mac uses to map domain names to IP addresses before checking DNS servers. It’s one of the oldest networking tools in Unix-based systems and still plays an active role today.

In everyday use, the hosts file is often modified by applications to block certain server connections (commonly used in software activation workflows), or to create local development environments. When those applications get removed but the hosts file isn’t cleaned up, you can end up with leftover entries that block legitimate connections or cause unexpected behavior in other apps.

The hosts file on Mac is located at:

/private/etc/hosts

What does the default hosts file look like on Mac?

Here’s the default content of the hosts file on a clean macOS installation. If your hosts file has anything beyond these lines, it was added by an application or manually by a user.

##
# 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

This is what you want to restore your hosts file back to. Any lines beyond these are additions that may or may not still be needed.

How to restore the hosts file on Mac (step by step)

Step 1: Open Finder, press Command + Shift + G to open the Go to Folder dialog, then paste this path and press Enter.

/private/etc/hosts
Path to the hosts file on Mac
Navigate to the hosts file on Mac using this path

Step 2: Copy the hosts file to your Desktop or Documents folder first. You can’t edit the file directly inside the /etc folder without admin permissions, so copying it out is both a workaround and a backup in case anything goes wrong.

Copy the hosts file to Desktop as a backup
Copy the hosts file to Desktop or Documents before editing

Step 3: Open the copied hosts file with a text editor (TextEdit works fine). Delete everything in the file and replace it with the default content shown in the section above. Save the file when done.

Edit the hosts file and paste the default content
Replace the file content with the default hosts entries

Note: Before clearing everything out, scroll through the existing content first. If you recognize any entries that a specific app still needs (for example, a local development setup), keep those lines below the default content instead of deleting them.

Step 4: Copy the edited hosts file and paste it back into the /private/etc/ folder. When the confirmation dialog appears, click Replace and enter your admin password to confirm.

Replace the hosts file back into the etc folder
Click Replace and enter your password to save the restored file

Step 5: Restart your Mac so the changes take effect. macOS caches DNS and hosts file data, so a restart ensures the system picks up the updated file properly.

Alternative method: Restore via Terminal

If you’re comfortable with Terminal, this is actually the faster approach. Open Terminal and run the following command to open the hosts file directly in the nano text editor with admin permissions:

sudo nano /private/etc/hosts

Enter your password when prompted. Once the file is open, use the arrow keys to navigate and delete any lines that shouldn’t be there. When you’re done, press Control + O to save, then Control + X to exit nano.

After saving, flush the DNS cache so macOS applies the changes immediately without needing a full restart:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

This is the same command Apple officially recommends for flushing DNS on macOS Ventura, Sonoma, and Sequoia (macOS 15).

How do you know if the hosts file is causing a problem?

Not sure if the hosts file is the culprit behind your connection issue? Here are some common signs that something in the hosts file is blocking a connection:

  • A specific app or website works fine on other devices but not on your Mac.
  • After uninstalling an app (especially Adobe products or software that uses license servers), something else stops connecting properly.
  • You see “server not found” or connection timeout errors for a domain that’s definitely up and running.
  • Opening the hosts file reveals entries pointing domains to 0.0.0.0 or 127.0.0.1, which effectively blocks those domains from being reached.

When should you NOT wipe the hosts file clean?

Before clearing everything, it’s worth pausing to consider a few scenarios where the extra entries might actually be intentional:

  • Local development: If you use tools like Laravel Valet, MAMP, or similar, they often add local domain entries to the hosts file. Wiping them will break your local dev setup.
  • Ad/tracker blocking: Some users manually add hundreds of ad server domains pointing to 0.0.0.0 as a system-level ad blocker. If you set this up intentionally, don’t clear it.
  • Custom domain routing: If you’re testing a website on a staging server and you’ve pointed a domain manually to a specific IP, that’s a legitimate entry worth keeping.

When in doubt, make a backup of the original file before making any changes. That way you can always restore it if something breaks.

Conclusion

Restoring the hosts file to its default state is one of the first things worth trying when an app suddenly can’t connect to its server, especially after you’ve uninstalled something. It takes about two minutes and doesn’t require any third-party software.

Use the Finder method if you prefer working visually, or the Terminal method if you want it done faster with a DNS flush included. Either way, a quick restart (or flush) afterward and you should be good to go.

If you’re still having connection issues after restoring the hosts file, drop a comment below with what app is affected and I’ll try to help you narrow it down!

Hieu Tran Ngoc Minh

Hieu (born in 1996) holds a Bachelor's degree in Business Administration from Saigon Technology University. Currently a Data Analyst at Ninja Van, Hieu has extensive experience in Data Analysis and Digital Marketing. This blog is where Hieu shares practical experiences from work and life.

4 Comments

  1. I can’t replace my hosts as ‘The operation can’t be completed because the item “hosts” is in use.’ how now

    Reply
  2. Do I need to edit the host file? Which line? Want to install Adobe software family on my mac Sonoma 14.2.1..

    Reply

Leave a Comment

Feel free to leave your comment (preferably in English), and we will review and respond as soon as possible. Please use a real email to ensure your comment is approved and to receive notifications when we reply. You can also add an avatar to your email.