Visit Website

How to Edit Hosts File in Windows | Open & Modify Hosts File Easily (Step-by-Step Guide)

The hosts file in Windows lets you control how your computer resolves website names. By editing it, you can block websites, redirect domains, or test local servers — all without installing any extra software.

This guide shows how to open and edit the hosts file in Windows 10/11 safely and easily.


🔍 What Is the Hosts File?

The hosts file is a system text file that maps:

  • Domain namesIP addresses

Before Windows checks the internet or DNS servers, it checks the hosts file first.

📌 That means entries in the hosts file can override normal DNS behavior.


📂 Hosts File Location in Windows

The hosts file is located at:

C:\Windows\System32\drivers\etc\hosts

⚠️ Administrator permission is required to edit this file.


✅ Method 1: Edit Hosts File Using Notepad (Recommended)

🧾 Step-by-Step Instructions:

  1. Click Start Menu

  2. Search for Notepad

  3. Right-click Notepad → select Run as administrator

  4. In Notepad, click File → Open

  5. Go to:

    C:\Windows\System32\drivers\etc
    
  6. Change file type from Text Documents (*.txt) to All Files

  7. Select hosts and click Open


✍️ How to Add Entries to Hosts File

At the bottom of the file, add entries like:

127.0.0.1   example.com
127.0.0.1   www.example.com

💡 This blocks the website on your PC.

To redirect a domain:

192.168.1.10   mylocaltest.com

💾 Save the File

  1. Press Ctrl + S

  2. Close Notepad

Changes take effect immediately.


✅ Method 2: Edit Hosts File Using Notepad++ (Advanced Users)

  1. Open Notepad++ as administrator

  2. Navigate to the hosts file location

  3. Edit and save changes

✔ Useful for syntax highlighting and large edits.


🔄 Clear DNS Cache (Optional but Recommended)

After editing, clear DNS cache to apply changes faster:

  1. Open Command Prompt as administrator

  2. Type:

    ipconfig /flushdns
    
  3. Press Enter


⚠️ Important Safety Tips

✔ Always create a backup before editing
✔ Do not delete existing system entries
✔ Use correct IP addresses
✔ Edit only if you know what you’re doing

❌ Wrong entries can block important websites or internet access.


🧠 Common Uses of Hosts File

  • 🚫 Block distracting websites

  • 🧪 Test local development sites

  • 🔐 Prevent malware domains

  • 🌐 Override DNS temporarily


❓ Frequently Asked Questions

Q1. Is it safe to edit the hosts file?

Yes, if done carefully with administrator permission.

Q2. Why can’t I save the hosts file?

You must open the editor as administrator.

Q3. How do I undo changes?

Remove the added lines or restore the backup file.

Q4. Does hosts file work without internet?

Yes. It works locally on your system.

Q5. Does editing hosts file affect all browsers?

Yes. It affects all browsers and apps on the system.


🏁 Conclusion

Editing the hosts file in Windows is a powerful and simple tool when used correctly.

📝 No extra software
⚙️ Works system-wide
🔐 Useful for blocking, testing, and security

Just remember: make a backup and edit carefully.


Complete Video Guide/Tutorial


Post a Comment

“Have questions? Drop your comment below 👇 We love to hear from you!”
Visit Website
Visit Website