How to Edit the Hosts File in Windows 11? How to Find & Identify?
The hosts file is a plain-text system file used by Windows to map hostnames to IP addresses. When you type a website address in your browser, Windows first checks the hosts file before contacting a DNS server. If a match is found in the hosts file, Windows uses that entry instead of searching online.
Because this file directly affects internet connections, Windows protects it from unauthorized changes. You cannot edit it like a normal text file without administrative privileges. To successfully edit the hosts file in Windows 11, you must open a text editor such as Notepad with administrator rights and manually locate the file.
The hosts file is stored in a system folder that is usually hidden from regular access. It is located inside the Windows installation directory, specifically within the drivers and etc folder. After opening it with administrator access, you can add new entries or modify existing ones.
Each entry in the hosts file follows a simple format. The IP address comes first, followed by the domain name. For example, entering 127.0.0.1 followed by a domain name will block that website on your computer by redirecting it to your local machine.
After making changes, saving the file correctly is crucial. If you do not run Notepad as an administrator, Windows will not allow you to save changes to the hosts file. Once saved, the new settings usually apply immediately, although sometimes you may need to clear the DNS cache.
Now, let’s know the steps to edit these files!
How to Edit the Hosts File in Windows 11?

To edit the hosts file in Windows 11, open Notepad as an administrator, navigate to the hosts file located in the System32 drivers etc folder, make your changes, and save the file. Administrator access is required because the hosts file is a protected system file that controls domain name resolution on your computer.
Editing the hosts file allows you to manually assign domain names to IP addresses. This helps you block specific websites, redirect domains, or test local servers.
The following steps explain the entire process simply and safely.
Step 1: Open Notepad as Administrator
The first step is to open Notepad with administrator privileges. Without administrative access, you will not be able to edit or save the hosts file.
Click on the Start menu and type Notepad in the search bar. When Notepad appears in the results, right-click on it and select Run as administrator. A User Account Control prompt will appear asking for permission. Click Yes to continue.
Opening Notepad as an administrator ensures that you have the necessary permissions to modify system files. If you skip this step, Windows will prevent you from saving any changes to the hosts file later.
Once Notepad opens in administrator mode, you are ready to locate the hosts file.
Step 2: Locate the Hosts File in Windows 11
After opening Notepad with administrative rights, the next step is to navigate to the location of the hosts file.
In Notepad, click on the File option in the top menu and select Open. A file explorer window will appear. Now navigate to the following path on your computer:
C:\Windows\System32\drivers\etc
By default, you may not see the hosts file in this folder. This happens because Notepad is set to display only text documents. Look at the bottom right corner of the open window and change the file type from Text Documents to All Files. Once you select All Files, the hosts file will become visible.
Click on the hosts file and then click Open. The file will now open in Notepad, allowing you to view and edit its contents.
You will see several lines starting with the hash symbol. These are comments explaining how the hosts file works. You can leave them as they are. Any new entry you add should be placed on a new line below the existing text.
Step 3: Understand the Format Before Editing
Before making any changes, it is important to understand the correct format used in the Windows hosts file.
Each line in the hosts file maps an IP address to a domain name. The IP address appears first, followed by at least one space, and then the domain name. For example, entering 127.0.0.1 example.com will redirect the website example.com to your local computer.
This method is commonly used to block websites. When a website is redirected to the local address 127.0.0.1, the browser cannot load it from the internet. This effectively blocks access to that domain on your computer.
If you want to redirect a domain to another server, you can enter a different IP address instead of 127.0.0.1. Make sure each entry is placed on a new line and follows the correct format.
Avoid deleting default entries unless you are sure about what you are doing. Incorrect edits may cause network issues or prevent certain websites from loading properly.
Step 4: Edit the Hosts File
Now you can begin editing the hosts file according to your needs.
Scroll to the bottom of the file and click on a new empty line. Enter the IP address followed by the domain name you want to block or redirect. For example, you can type 127.0.0.1 followed by a website address to block that website on your system.
You can add multiple entries if needed. Each entry must be on a separate line. Make sure there are no extra characters or spaces before the IP address. Incorrect formatting may prevent the entry from working.
If you are testing a website locally, you can map a domain to a local server IP address. This is often used by developers to test websites before making them live.
Take your time while editing and double-check all entries. Since the hosts file directly affects internet access, even small errors can cause connection issues.
Step 5: Save the Hosts File Properly
After making the necessary changes, you must save the hosts file correctly.
Click on the File option in Notepad and select Save. Because you opened Notepad as an administrator, Windows will allow you to save the changes directly. If you are prompted to confirm, click Yes.
Once saved, the changes are usually applied immediately. However, if the changes do not take effect right away, you may need to clear the DNS cache. You can do this by opening Command Prompt as an administrator and typing the command ipconfig /flushdns, then pressing Enter.
Saving the file correctly ensures that your new settings are applied without errors.
Step 6: Verify Your Changes
After saving the hosts file, it is a good idea to verify that your changes are working.
Open your web browser and try accessing the website you blocked or redirected. If you blocked a site using 127.0.0.1, the website should not load. If you redirected a domain to a different IP address, it should open from the new location.
If the changes do not appear, restart your browser or clear the DNS cache again. Sometimes Windows or the browser may store old DNS information that needs to be refreshed.
Verifying your changes helps confirm that the hosts file has been edited successfully and is functioning as expected.
Faqs
What is the hosts file in Windows 11?
The hosts file is a system file that maps domain names to IP addresses. It allows Windows to resolve domain names locally before contacting external DNS servers. This file can be used to block or redirect websites.
Do I need administrator rights to edit the hosts file?
Yes, you must open a text editor such as Notepad with administrator privileges to edit the hosts file. Without administrative access, Windows will not allow you to save changes.
Where is the hosts file located in Windows 11?
The hosts file is located in the following directory:
C:\Windows\System32\drivers\etc
You must navigate to this folder from within Notepad opened as an administrator to edit the file.
How do I block a website using the hosts file?
To block a website, add a new line at the bottom of the hosts file and type 127.0.0.1 followed by the website address. Save the file, and the website will be blocked on your computer.
Is it safe to edit the hosts file?
Yes, it is safe if you know what you are doing. Avoid deleting default entries and ensure correct formatting. Incorrect entries may cause network or browsing issues.
