Skip to content
Follow
Windows

How to Edit the Hosts File in Windows 11

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

The Hosts file in Windows 11 lets you map website names to specific IP addresses before your computer checks the internet. Located at 📁C:\Windows\System32\drivers\etc\hosts, this plain text system file acts as a local routing table to block unwanted domains, redirect web traffic, or test local servers.

Advertisement

Windows hides system file changes by default, so you need administrator permissions and a text editor like Notepad to make updates. Changing these entries gives you direct control over how your PC resolves web addresses on your local network.

⚡ 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

Advertisement

Why Would You Edit the Hosts File?

Editing the hosts file in Windows 11 lets you manually map website names to specific IP addresses. You typically use this method to block unwanted websites, test new web designs on your local machine before they go live, or bypass DNS routing issues on your local network.
  • 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 Windows 11 hosts file is a plain text document containing IP addresses followed by matching website names. Each entry sits on its own separate line, and any line beginning with a hash symbol acts as an ignored note rather than an active rule.

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

127.0.0.1 localhost

Advertisement

# 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

Opening Notepad as an administrator is required because Windows 11 protects the system folder where the hosts file lives. Launching the text editor with elevated permissions gives you the necessary rights to save your edits without getting permission errors.

  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

Advertisement

Step 2Open the Hosts File in Notepad

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

Opening the Hosts file in Notepad with administrative permissions lets you edit and save changes. This is necessary because the Hosts file needs elevated privileges to prevent unauthorized changes.

Step 3Add Your Changes

💡TipScroll 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.

Advertisement
Saving hosts file in Notepad
windows 11 hosts file save

💡TipYour changes will take effect immediately — no restart needed!

Tips and Things to Remember

Backing up your original hosts file before making any changes prevents accidental lockouts or broken internet connections. Always verify your administrative permissions before saving, and use the hash symbol to disable lines temporarily 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.

Editing the hosts file in Windows 11 gives you direct control over how your computer resolves website addresses for blocking or testing purposes. Success requires running Notepad as an administrator and saving a backup copy of the original document before making changes.

Was this guide helpful?

Tags: #Windows 11
Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 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 *