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 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.
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?
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:
C:\Windows\System32\Drivers\etc\hostsWhat 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
# 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.
- Click on the Start button or press the Windows key.
- Type
Command Promptin the search box. - Right-click on Command Prompt in the results and select Run as administrator.

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
For example, to make your computer treat example.com as your own local computer (useful to block or test the site), add this line:
127.0.0.1 example.comStep 4Save Your Changes
Click File Save in Notepad to save the file.

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?
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.
No comments yet — be the first to share your thoughts!