The hosts file in Windows 11 and Windows 10 is a small but important system file that helps your computer connect domain names to specific IP addresses. Before your computer uses a DNS server to look up a website’s address, Windows can check the hosts file for a matching entry. This makes the file useful for website testing, local development, troubleshooting network issues, and blocking access to certain domains.
However, finding the hosts file can be confusing if you have never worked with Windows system files before. It does not usually appear in the regular folders you use every day, and modifying it requires administrator permissions.
In this guide, you will learn where the hosts file is stored in Windows 11 and Windows 10, how to open and modify it safely, how to save your changes, and what to do if your edits do not work.
Let’s start the guide!
Find Hosts File Location in Windows 11/10 to Modify or Other Things

To find and modify the hosts file in Windows 11 or Windows 10, follow these steps:
- Open File Explorer by pressing Windows + E on your keyboard.
- Navigate to C:\Windows\System32\drivers\etc.
- Find the file named hosts in the etc folder.
- To edit it, open Notepad as an administrator from the Start menu.
- In Notepad, select File > Open and navigate to the hosts file location.
- Change the required entries carefully and select File > Save.
- Open Command Prompt and run ipconfig /flushdns if you need to clear the DNS resolver cache.
Step 1: Open File Explorer in Windows 11 or Windows 10
The easiest way to locate the hosts file is through File Explorer. This method works on both Windows 11 and Windows 10 and does not require you to remember a complicated navigation process.
Press Windows + E on your keyboard to launch File Explorer. You can also click the File Explorer icon on the taskbar or search for File Explorer through the Start menu.
Once File Explorer opens, click the address bar at the top of the window. Enter the following path exactly as shown:
C:\Windows\System32\drivers\etc
Press Enter to open the folder. You should now see several files associated with Windows network configuration, including the file named hosts.
This is the standard hosts file location for both Windows 11 and Windows 10. You do not need to download anything or install a separate utility to access it.
If you prefer to navigate manually, follow this path: This PC > Local Disk (C:) > Windows > System32 > drivers > etc. Open each folder in sequence until you reach the destination.
Step 2: Locate the Hosts File in the etc Folder
After opening the etc folder, look for a file named hosts. The file usually has no extension, so you will not see .txt or another familiar file extension after its name.
If you cannot find it immediately, check the file list carefully. Windows may display the file type as a generic file rather than identifying it as a text document.
You can also click the search box in File Explorer and search for hosts while you are inside the etc folder. However, checking the folder directly is often faster because it contains only a limited number of files.
Remember that the correct location is C:\Windows\System32\drivers\etc\hosts. Do not confuse this file with another file named hosts that may exist in an application folder or a project directory.
At this point, you have located the file. You can inspect it, copy it for backup purposes, or open it with a text editor. If your goal is to modify its contents, the next step explains the safest way to do that.
Step 3: Open Notepad With Administrator Permissions
Although you can locate the hosts file using File Explorer, editing it directly may fail because Windows protects this system location. To save changes successfully, you should launch your text editor with administrator privileges.
Click the Start menu and type Notepad into the search box. When Notepad appears in the results, right-click it and select Run as administrator. If Windows displays a User Account Control prompt, review it and select Yes if you want to proceed.
Opening Notepad this way gives the application the permissions needed to modify protected system files, provided your Windows account is authorized to make those changes.
Next, select File > Open in Notepad. Navigate to C:\Windows\System32\drivers\etc.
If the folder looks empty, check the file type menu near the bottom of the Open dialog. Notepad may be set to display only text documents. Change the selection from Text Documents (*.txt) to All files (.).
You should now be able to see the hosts file. Select it and click Open.
This method is generally more reliable than double-clicking the file in File Explorer because it allows you to open the protected file in an editor that already has the necessary permissions.
Step 4: Understand the Existing Hosts File Entries
Before making any changes, take a moment to understand what the hosts file contains. You will usually see comments explaining its purpose, along with example entries that begin with the number sign (#).
A line beginning with # is a comment. Windows ignores it when processing host mappings. These comments can explain how the file works or provide instructions for administrators.
A typical active entry contains an IP address followed by a hostname. For example:
127.0.0.1 localhost
The IP address 127.0.0.1 refers to your own computer through the IPv4 loopback interface. The hostname localhost is commonly used to refer to the local machine.
Another example is:
192.168.1.50 test.example.com
This entry tells Windows to associate test.example.com with the specified IP address when resolving that hostname through the hosts file.
You can place multiple hostnames after an IP address, separating them with spaces or tabs. Each separate mapping should be entered on its own line for clarity.
The hosts file is a plain-text configuration file, so avoid adding formatting, decorative symbols, or unrelated instructions. Incorrect entries can cause websites or applications to connect to the wrong address or fail to connect at all.
Step 5: Modify the Hosts File for Your Requirements
Now that you understand the file’s format, you can modify it according to your needs. Common uses include testing a website before DNS changes are made, directing a development hostname to a local server, or overriding the normal address resolution of a particular domain.
For example, if you are testing a local website, you might add this entry:
127.0.0.1 mysite.test
This maps mysite.test to your own computer. It does not create a website or start a web server, so the mapping will work as intended only if an appropriate local service is configured.
If you need to point a hostname to a different server, replace 127.0.0.1 with the correct IP address. Make sure the hostname is spelled correctly and that you have permission to make the change.
You may also encounter guides that use the hosts file to block domains by mapping them to an address such as 0.0.0.0. Although this can interfere with access to a domain, it is not a complete or dependable security solution. Applications may use alternative hostnames, direct IP addresses, proxies, or their own DNS mechanisms.
Once you have entered the required mapping, review the entire file. Do not remove existing entries unless you understand why they are there. Avoid changing unrelated Windows configuration lines, since doing so may create additional network problems.
Step 6: Save Your Changes and Check for Errors
After editing the file, select File > Save in Notepad or press Ctrl + S. If Notepad is running with administrator permissions, your changes should save to the original hosts file.
If you receive an error stating that you do not have permission to save the file, confirm that you opened Notepad using Run as administrator. Then reopen the original hosts file and repeat your changes.
Be careful not to save the file as hosts.txt. Windows may hide known file extensions, making it easy to accidentally create a separate text document instead of modifying the actual hosts file.
The correct filename is simply hosts, without a file extension. If you use the Save As dialog, choose All files in the file type menu and enter hosts as the filename. However, saving the original file directly from an elevated Notepad window is preferable.
For additional safety, create a backup before making significant changes. You can copy the original hosts file to another folder and keep that copy until you confirm everything works as expected.
Step 7: Flush the DNS Cache and Test the Changes
Windows may keep recently resolved domain names in its DNS resolver cache. After modifying the hosts file, flushing this cache can help you test the updated mapping without relying on older cached information.
Open the Start menu, search for Command Prompt, right-click the result, and select Run as administrator. Approve the User Account Control prompt if necessary.
Enter the following command and press Enter:
ipconfig /flushdns
Windows should display a message indicating that the DNS resolver cache was successfully flushed.
Next, test the hostname you changed. You can use the ping command with the hostname or run nslookup if you need to investigate DNS behavior. Keep in mind that nslookup queries DNS servers directly and generally does not use the Windows hosts file, so its output may differ from the result used by applications.
If the change still does not work, verify that the IP address and hostname are correct, that the entry is not commented out, and that the file was saved without an extension. Also check whether the application uses a proxy, its own DNS resolver, or another method of resolving names.
Restoring the Hosts File if Something Goes Wrong
If a website or application stops working after you edit the hosts file, the quickest troubleshooting method is to review the entries you recently added.
Open the hosts file again using Notepad as an administrator and remove or correct the problematic mapping. Save the changes and run ipconfig /flushdns once more.
If you created a backup before editing, you can compare the current file against that copy and restore the original contents when appropriate. Keep in mind that some computers may have legitimate custom entries configured by an administrator, developer, or organization.
If you are using a work or school computer, check with your IT administrator before removing unfamiliar entries. A managed device may depend on custom hostname mappings for internal services.
You should also remember that resetting the hosts file is not the same as resetting all network settings. If the problem continues after correcting the file, investigate other possible causes, such as DNS configuration, firewall rules, proxy settings, or network connectivity.
Faqs
Where is the hosts file located in Windows 11?
The default location is C:\Windows\System32\drivers\etc\hosts. You can paste the folder path into File Explorer’s address bar and select the file named hosts.
Is the hosts file location different in Windows 10?
No. Windows 10 and Windows 11 use the same default hosts file location: C:\Windows\System32\drivers\etc\hosts.
Why can’t I edit the hosts file?
Windows protects the file because it affects hostname resolution. Open Notepad using Run as administrator, then open the hosts file from Notepad. You also need an account with sufficient permissions to make the change.
Why can’t I see the hosts file in File Explorer?
The file may be difficult to spot because it has no extension. You can also search within the etc folder or open the folder directly using its full path. In Notepad’s Open dialog, select All files (.) if the file is not visible.
Can I delete the hosts file?
You generally should not delete it. The file may contain default entries or custom mappings needed by your computer. If you suspect that its contents are incorrect, back it up and correct the entries instead of deleting the file.
Do I need to restart Windows after modifying the hosts file?
Usually, no. Save the file and flush the DNS resolver cache if necessary. You may need to restart an application if it maintains its own DNS cache or has an active connection to the old address.
Can the hosts file block websites?
Yes, it can interfere with hostname resolution for specific domains. However, it is not a comprehensive website-blocking or cybersecurity tool, and its effectiveness varies depending on the application and the way the domain is accessed.