Windows 11 edit hosts file

How to edit HOSTS file on Windows

Do you need to edit the hosts file? Here's how on any supported version of Windows.

  • To edit the “Hosts” files on Windows, open PowerToys > Host editor, and click “Launch Hosts File Editor,” “Accept,” and “New entry.” Then, create the entry with IP address, hostname, and comment, turn on the “Active” option, and click “Add.”
  • To edit the “Hosts” file from Notepad (admin), open File > Open, and browse to the “C:\Windows\System32\Drivers\etc” location and open the “hosts” file. Add a new IP address and domain mapping – for example,
  • If you can’t edit the Hosts file, it’s because you need administrative permissions on Windows 11.

On Windows 11 (and 10), 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 C:\Windows\System32\Drivers\etc path on Windows 11. (It’s the same path on Windows 10.) 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 11 and Windows 10 make it super simple to edit the Hosts file using Notepad or any other text editor as long as you open the app as an administrator. Otherwise, you won’t be able to edit the file. In addition, the PowerToys app includes a tool that makes it easier to manage entries in the Hosts file. Alternatively, you can also use Command Prompt to edit the Hosts file.

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

Edit Hosts file on Windows from PowerToys

To edit the Hosts files with the PowerToys editor, use these steps:

  1. Open PowerToys.

  2. Click on Hosts File Editor.

  3. Under the “Activation” section, click the “Launch Hosts File Editor” option.

    PowerToys Hosts File Editor

  4. Click the Accept button for the warning.

  5. Click the New entry button.

    Hosts File Editor new entry

  6. Confirm the IP address, hostname, and comment (as necessary).

    Windows 11 edit Hosts file

  7. Turn on the Active button.

  8. Click the Add button.

  9. (Optional) Right-click the entry and choose the “Delete” option for a specific configuration.

After you complete the steps, the Hosts file will save with the new entries, and you should now be able to test the new configuration. In the editor, you can enable or disable entries with a toggle switch.

Edit Hosts file on Windows from Notepad

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

  1. Open Start.

  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.

    Open 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.

    Windows 11 edit hosts file

    Quick note: If you want to add another entry, use a new line and don’t use the pound sign (#) since that symbol is only used for commenting.
  9. (Optional) Delete the entire line to remove the entry from the Hosts file.

  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 can edit the “Hosts” file on Windows 11, it’s because you need administrative permissions.

Edit Hosts file on Windows from Command Prompt

To edit the “Hosts” file through Command Prompt, use these steps:

  1. Open Start.

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

  3. Type the following command to add another entry to the Hosts file and press Enter:

    echo >> %SystemRoot%\System32\drivers\etc\hosts

    In the command, replace “” for the entry you want to include in the file.

    Command Prompt edit Hosts

  4. (Optional) Type the following command to confirm the changes and press Enter:

    type %SystemRoot%\System32\drivers\etc\hosts

After you complete the steps, the entry will be added to Hosts file. 

Since the Hosts file is a text file, if you want to remove an entry, the easiest way to complete this configuration from Command Prompt is to run the notepad %SystemRoot%\System32\drivers\etc\hosts command to open the file and delete the line to remove the entry and save the file.

Update April 22, 2024: This guide has been updated to ensure accuracy and reflect changes to the process using Command Prompt.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and Email him at [email protected].