Skip to content
Follow
Windows

How to Edit the Hosts File in Windows 11

Richard
Written by
Richard
Jan 27, 2026 Updated Jun 19, 2026 4 min read
How to Edit the Hosts File in Windows 11
How to Edit the Hosts File in Windows 11

You can edit the Hosts file in Windows 11 to control website access and test local server configurations.

The Hosts file is a system file located at 📁C:\Windows\System32\drivers\etc\hosts that maps domain names to IP addresses, overriding your normal DNS lookups.

Editing the Windows hosts file allows users to manually block specific websites, redirect website traffic to different IP addresses, or test local server behavior before deployment. For instance, users can employ the hosts file to block unwanted advertisements or to restrict access to a website currently under development.

⚡ Quick Answer

Open Notepad as administrator, then type notepad.exe C:WindowsSystem32Driversetchosts into the Command Prompt. Edit the file, and save your changes via File > Save.

Why Would You Edit the Hosts File?

You can edit the hosts file in Windows 11 for several useful reasons, like blocking websites you don’t want to visit, testing new websites on your own computer before they’re public, or fixing network problems by telling your computer which IP address a website name should use.
  • Block websites: Stop your computer from visiting certain websites by redirecting them.
  • Test websites: Web developers use the Hosts file to test websites on their own computer before making them live.
  • Fix network issues: Sometimes you want to link a name to a specific IP address for easier local access.

Where is the Hosts File Located?

The Hosts file is stored in this location on your computer:

💻Code
C:\Windows\System32\Drivers\etc\hosts

What Does the Hosts File Look Like?

The hosts file in Windows 11 is a simple text document that lists IP addresses and website names, connecting them line by line; lines starting with a ‘#’ symbol are ignored and act as comments.

# This is a comment - lines starting with # are ignored by your computer

127.0.0.1 localhost

# 127.0.0.1 example.com (this line is ignored because it starts with #)

To edit the hosts file in Windows 11, ensure the IP address and website name you enter have at least one space or tab separating them. This spacing prevents incorrect mapping of IP addresses to domain names, which could stop you from reaching certain websites.

How to Edit the Hosts File: Step-by-Step

Step 1Open Notepad as Administrator

⚠️Warning
To edit the hosts file in Windows 11, you must first open Notepad as an administrator, which gives it the special permission needed to change important network settings.
  1. Click on the Start button or press the Windows key.
  2. Type Command Prompt in the search box.
  3. Right-click on Command Prompt in the results and select Run as administrator.
Opening Command Prompt as Administrator in Windows 11
windows 11 command prompt administrator

Step 2Open the Hosts File in Notepad

In the Command Prompt window, type the following command and press Enter:

⚠️Warning
Opening the Hosts file in Notepad with administrative permissions allows users to edit and save changes to the file. This action is necessary because the Hosts file requires elevated privileges for modification to prevent unauthorized alterations.

Step 3Add Your Changes

Scroll to the bottom of the file and add your new entries. For example, to make your computer treat example.com as your own local computer (useful to block or test the site), add this line:

💻Code
127.0.0.1    example.com

Step 4Save Your Changes

Click File > Save in Notepad to save the file.

Saving hosts file in Notepad
windows 11 hosts file save

Your changes will take effect immediately — no restart needed!

Tips and Things to Remember

When you edit the hosts file in Windows 11, remember to always run Notepad as an administrator, make a backup copy of the original file first, and use the ‘#’ symbol to add notes or temporarily turn off lines without deleting them.
  • Always run Notepad as administrator to make sure you can save the changes.
  • Make a backup: Before you edit, copy the original Hosts file somewhere safe. This way, you can restore it if something goes wrong.
  • Use # for comments: If you want to disable a line without deleting it, just put a # at the start of that line.
  • Changes are instant: After saving, your computer immediately uses the new settings.

Summary

  • The Hosts file lets you control how your computer finds websites.
  • You can block websites or test your own sites locally.
  • You must run Notepad as an administrator to edit and save the file.
  • Always save a backup before making changes.

The Hosts file in Windows 11 lets you control how your computer finds websites, allowing you to block specific sites or test your own websites locally before they go live.

Is it safe to edit the hosts file?

Security teams use the hosts file to block malicious domains locally. Even regular users sometimes update the hosts file to restrict access to distracting websites. Because the hosts file is local, any changes you make apply only to that specific computer.

Was this guide helpful?

Tags: #Windows 11
Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Edit Hosts File with PowerToys on Windows 11
Windows How to Edit Hosts File with PowerToys on Windows 11
Advanced Windows 11 Guide For Developers
Windows Advanced Windows 11 Guide For Developers
How To Fix Windows 11 Wi-Fi Connection Issues
Windows How To Fix Windows 11 Wi-Fi Connection Issues
How to Access Settings in Windows 11
Windows How to Access Settings in Windows 11

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *