Skip to Content

How To Edit The hosts File on Windows 11


July 31st 2023


How To Edit The hosts File on Windows 11

The hosts file on Windows 11 is used to map hostnames (often referred to as domain names) to specific IP addresses, overriding DNS resolution. This means that you can redirect a hostname such as www.websitename.com to any IP address you want. This is particularly useful when DNS isn’t working properly! Be aware that it only applies to your local computer and can cause problems if done incorrectly. To manually edit the hosts file and redirect a hostname to a specific IP address, follow these steps or skip to the bottom for the faster PowerShell method for experienced users, contributed by Hunter from KIT Professionals.

Manual Method

Editing the hosts file on Windows 11 is quite similar to how it's done on previous Windows versions. To edit the hosts file and redirect a domain name to a specific IP address, follow these steps:

  1. Open File Explorer: Press Windows key + E to open File Explorer or access it through the Start menu.

  2. Navigate to the Hosts File: The hosts file is located in the C:\Windows\System32\drivers\etc directory. By default, you won't see the file in the folder, as it is hidden. To make it visible, click on the "View" tab in File Explorer, and check the "Hidden items" option.

  3. Copy the Hosts File: Before editing the file, it's a good idea to create a backup. Right-click on the hosts file, select "Copy," then right-click in the same directory and choose "Paste" to create a duplicate named hosts - Copy.

  4. Open Notepad as Administrator: To edit the hosts file, you need administrative privileges. Search for "Notepad" in the Start menu, right-click on "Notepad," and select "Run as administrator." Confirm the UAC prompt if asked.

  5. Open the Hosts File: In Notepad, go to "File" > "Open" and navigate to C:\Windows\System32\drivers\etc. Make sure to select "All Files" from the file type dropdown to see the hosts file.

  6. Edit the Hosts File: The hosts file contains lines of text with IP addresses and domain names. To redirect a domain name to a specific IP address, add a new line at the end of the file in the following format:

    <IP Address> <Domain Name>

    Replace <IP Address> with the specific IP address you want to redirect the domain to, and <Domain Name> with the domain you want to redirect. For example:

    192.168.1.100 example.com

    This line will redirect "example.com" to the IP address "192.168.1.100".

  7. Save the Hosts File: After making the necessary changes, save the hosts file by clicking on "File" > "Save" in Notepad.

  8. Flush DNS Cache: To apply the changes immediately, you need to flush the DNS cache. Open Command Prompt as Administrator by searching for "Command Prompt" in the Start menu, right-clicking it, and selecting "Run as administrator." In the Command Prompt, type the following command and press Enter:

    ipconfig /flushdns

    This will flush the DNS cache, so your system will start using the updated hosts file.


PowerShell Method

For those comfortable with PowerShell, Hunter from KIT Professionals shared an efficient method to edit the hosts file quickly:

Backup the Hosts File

  1. Press Windows key + R to open the Run window.

  2. Paste the following command and press Ctrl+Shift+Enter to run it with admin privileges:

    copy "C:\Windows\System32\drivers\etc\hosts" "C:\Windows\System32\drivers\etc\hostsBACKUP"

Verify Backup File Exists

  1. Press Windows key + R to open the Run window.

  2. Paste this command and press Enter:

    notepad C:\Windows\System32\drivers\etc\hostsBACKUP

    If the backup file opens in Notepad, you’re good to proceed.

Open Hosts File for Editing

  1. Press Windows key + R to open the Run window.

  2. Paste this command and press Ctrl+Shift+Enter to open Notepad as an administrator:

    notepad "C:\Windows\System32\drivers\etc\hosts"
  3. Make the necessary changes and press Ctrl+S to save.

Note: The hosts file doesn’t affect nslookup results. Use ping instead.


Now, when you access the domain you've redirected in your web browser, it should go to the specified IP address instead of the regular DNS resolution. Keep in mind that this change only affects your local system, and other devices on the network won't be affected by this modification.

Once you've finished working with a custom hosts file entry, it’s best to remove it to avoid confusion in the future. If you need further assistance with IT solutions, check out KIT Professionals for expert support.


Find more technical support articles on our blog!

Google Play store page