🛠️ How to Edit the Hosts File in Windows (Step-by-Step)

Need to block a site or redirect a domain locally? Editing the hosts file is the fastest way to do it on Windows.

📍 What Is the Hosts File?

The hosts file is a local file used by Windows to map domain names to IP addresses — it takes priority over DNS.

⚙️ How to Edit the Hosts File (Simple Steps)

  • Search for Notepad, right-click it, and choose Run as administrator
  • Go to File > Open
  • Open this folder: C:\Windows\System32\drivers\etc
  • Change file type to All Files and open the hosts file
  • Add this line at the bottom: 127.0.0.1 example.com
  • Save and close the file

🔐 Notes

  • You must run Notepad as administrator to edit the file
  • Each entry must be on its own line
  • No “#” in front of the line if you want it to be active

🧠 Final Tip

Editing the hosts file is a quick and powerful tool. Use it wisely!