How to edit HOSTS file on Windows

On Windows 11, you can edit the “Hosts” file to manually override the system’s Domain Name System (DNS) settings for a specific internet domain (website) or device connected to the local network.


Usually, you don’t have to worry about manually mapping an IP address to a domain name using the Hosts file located in the


path on Windows. However, it can come in handy in many scenarios. For instance, when you want to block certain websites. When you don’t have a local DNS server in the network, you must map an IP address to a computer name or prepare a website transfer to a new hosting provider.


Regardless of your reason, Windows makes it super simple to edit the Hosts file using Notepad or any other text editor application as long as you open the app as an administrator. Otherwise, you won’t be able to edit the file.


In this guide, you will learn the steps to modify the Hosts files on Windows 11 to map host names to IP addresses.

How to edit Hosts file on Windows

To edit the “Hosts” file on Windows 11, use these steps:


1) Open Start on Windows.


2) Search for Notepad, right-click the top result, and select the Run as administrator option.


3) Click on File and select the Open option.


4) Browse to the Hosts file location:



5) Use the drop-down menu next to “File name,” and select the “All Files” option.


6) Select the Hosts file.

7) Click the Open button.


8) In a new line, enter the IP address of the remote server, add at least one space, and confirm the domain name or computer name to reach the service. For example, #This PC redirects to the specified IP address.

9) (Optional) Type the following line to block a specific website (for example, Facebook): #This PC will block access to Facebook


10) Click on File.


11) Select the Save option.


Once you complete the steps, you can test the changes by opening Command Prompt and using the ping command to ensure the host is reachable.


If you want to block your computer from accessing certain websites, you can use the loopback address ( followed by the domain name ( Also, if you cant edit the “Hosts” file on Windows, it’s because you need administrative permissions.