Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Reset Hosts File to Default Values

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
  4. # This file contains the mappings of IP addresses to host names. Each
  5. entry should be kept on an individual line. The IP address should
  6. be placed in the first column followed by the corresponding host name.
  7. The IP address and the host name should be separated by at least one
  8. space.
  9. # Additionally, comments (such as these) may be inserted on individual
  10. lines or following the machine name denoted by a '#' symbol.
  11. # For example:
  12. # 102.54.94.97 rhino.acme.com # source server
  13. 38.25.63.10 x.acme.com # x client host
  14. localhost name resolution is handled within DNS itself.
  15. 127.0.0.1 localhost
  16. ::1 localhost
  17. Host Database
  18. # localhost is used to configure the loopback interface
  19. when the system is booted. Do not change this entry.
  20. 127.0.0.1 localhost
  21. The following lines are desirable for IPv6 capable hosts
  22. Common Mistakes
  23. Tips
  24. Troubleshooting
  25. Frequently Asked Questions

Resetting the hosts file to its default state removes custom entries that can block websites, redirect domains, or cause connectivity issues. This guide walks you through restoring the original file on Windows, macOS, and Linux, and covers what to do if the reset doesn't work as expected.

What You'll Need

  • Administrator or root access to your computer (to edit system files).
  • A text editor that can save files without adding formatting (e.g., Notepad on Windows, TextEdit in plain-text mode on macOS, or nano/vim on Linux).
  • For Windows: the exact default hosts file content (provided below).

Step-by-Step

Windows (10/11)

  1. Open Notepad as administrator: press Start, type Notepad, right-click it, and select Run as administrator.
  2. In Notepad, go to File > Open, navigate to C:\Windows\System32\drivers\etc, and change the file type filter from Text Documents (*.txt) to All Files (*.*).
  3. Select the hosts file and click Open. (If you don't see it, ensure you're looking in the correct folder and that hidden files are visible.)
  4. Delete all existing content and paste the default Windows hosts file content below:
# Copyright (c) 1993-2009 Microsoft Corp.

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

# This file contains the mappings of IP addresses to host names. Each

entry should be kept on an individual line. The IP address should

be placed in the first column followed by the corresponding host name.

The IP address and the host name should be separated by at least one

space.

# Additionally, comments (such as these) may be inserted on individual

lines or following the machine name denoted by a '#' symbol.

# For example:

# 102.54.94.97 rhino.acme.com # source server

38.25.63.10 x.acme.com # x client host

localhost name resolution is handled within DNS itself.

127.0.0.1 localhost

::1 localhost

  1. Save the file with File > Save. If you get a permission error, you may need to save to the desktop first, then copy it back to the etc folder (confirm the replacement).
  2. Flush the DNS cache to apply changes: open Command Prompt as administrator (type cmd in Start, right-click, run as admin) and run ipconfig /flushdns.

macOS (Ventura and later)

  1. Open Terminal (from Applications/Utilities).
  2. Back up the current file (optional but recommended): sudo cp /etc/hosts /etc/hosts.backup
  3. Edit the file with a command-line editor: sudo nano /etc/hosts
  4. Delete all lines and paste the default macOS hosts file content:
##

Host Database

# localhost is used to configure the loopback interface

when the system is booted. Do not change this entry.

127.0.0.1 localhost

255.255.255.255 broadcasthost ::1 localhost
  1. Press Ctrl+O to save, then Ctrl+X to exit.
  2. Flush DNS: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Linux (most distributions)

  1. Open a terminal.
  2. Edit the file with sudo: sudo nano /etc/hosts
  3. Replace the content with the default (adjust if your distro uses a different default, but this is standard):
127.0.0.1	localhost
127.0.1.1	your-hostname

The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
  1. Replace your-hostname with your actual machine hostname (check with hostname command).
  2. Save and exit (Ctrl+O, Ctrl+X in nano).
  3. Restart networking or reboot if necessary (most modern systems apply changes immediately).

Common Mistakes

  • Not running the editor as administrator/root – you'll get “Access denied” or “Permission denied” errors.
  • Saving with a .txt extension – Windows Notepad may append .txt if you don't set “Save as type” to “All Files”.
  • Using a word processor – Word or TextEdit in rich mode can add formatting or smart quotes that break the file.
  • Forgetting to flush DNS – changes may not take effect until you clear the cache.
  • Deleting the localhost entry – some programs rely on it; leaving it is safer.

Tips

  • Always make a backup of the original hosts file before editing. If something goes wrong, you can restore it.
  • Use a plain text editor like Notepad, nano, or vim. Avoid rich text editors.
  • Keep the file encoding as UTF-8 without BOM (Notepad's default is fine on Windows 10/11).
  • After resetting, test with a known blocked site to ensure the change took effect.
  • If you use a VPN or security software, they may modify the hosts file automatically; check their settings if changes revert.

Troubleshooting

“Access denied” when saving on Windows

Make sure Notepad is running as administrator. If it still fails, save the file to your desktop, then copy it into the etc folder using File Explorer (confirm when prompted).

Changes don't take effect

Flush DNS again. On Windows, run ipconfig /flushdns. On macOS, run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. On Linux, try sudo systemctl restart systemd-resolved or reboot.

File reappears with old content after reboot

Some security or parental-control software actively rewrites the hosts file. Check those programs' settings and disable any “hosts protection” or “web filtering” feature temporarily, then reset again.

Hosts file is missing entirely

On Windows, create a new file named hosts (no extension) in the etc folder and paste the default content. On macOS/Linux, the file should exist; if not, create it with sudo touch /etc/hosts and then edit.

Still can't access a site after reset

Clear your browser cache and try a different browser. Also check if the site is down for everyone (use an online status checker). If the issue persists, it may be due to DNS settings on your router or device, not the hosts file.

Frequently Asked Questions

Will resetting the hosts file affect my internet speed?

No. The hosts file is only used for local name resolution; resetting it removes custom mappings but does not change your connection speed.

Do I need to restart my computer after resetting?

Usually not. Flushing the DNS cache is enough. A reboot is only needed if the change doesn't apply after flushing.

Can I reset the hosts file on a Chromebook?

ChromeOS doesn't expose the hosts file to users. You can't edit it without developer mode, which is not recommended for most users.

What if I have a custom entry I want to keep?

Instead of resetting the entire file, manually remove only the unwanted lines and keep the ones you need. Always back up the file first.

Is it safe to delete the hosts file entirely?

No. The hosts file is required for localhost resolution and some system functions. Always replace it with the default content, not an empty file.

Why does the hosts file keep coming back with the same entries?

This is likely due to malware or security software that modifies the file. Run a full antivirus scan and review your security software's settings.