Some software adds entries to the hosts file on your Mac when it installs, and doesn’t always clean up after itself when you remove it. Common examples are VPN clients, ad blockers and developer tools. 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 can be edited by several sources. Some software, VPN clients and ad blockers use it to block connections to specific domains, and developers use it to set up local development environments. Malware can also modify the hosts file to redirect you to fake websites, so any entry you don’t recognize deserves a closer look. 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

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.

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.

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.

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 (for example a VPN client or an ad blocker), 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.0or127.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.0as 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!





I can’t replace my hosts as ‘The operation can’t be completed because the item “hosts” is in use.’ how now
Hello, please restart your mac and try again
Do I need to edit the host file? Which line? Want to install Adobe software family on my mac Sonoma 14.2.1..
Restore hosts file if you have old Adobe apps.