How to Edit the Hosts File in Windows 11

Published on August 7, 2023
How to Edit the Hosts File in Windows 11

The hosts file, a legacy from the early days of the internet, is still a useful tool for mapping IP addresses to hostnames. This guide will walk you through different methods to edit this file in Windows 11.

Quick Editing with Microsoft PowerToys Hosts File Editor

  1. Download and install PowerToys from Microsoft Store.
  2. Click Search on the taskbar and type 'PowerToys'. Open the application.
  3. Inside PowerToys, select Hosts File Editor from the left panel.
  4. Click 'Launch Hosts File Editor'. This tool requires admin privileges to edit the Hosts file.
  5. Accept the warning dialog.
  6. You will see all entries from your Hosts file. Add, delete, or reorder as needed.

Locating Hosts File in Windows 11

On modern versions of Windows, including Windows 11, the hosts file is located at %SystemRoot%\System32\drivers\etc\hosts.

Understanding the Hosts File

The hosts file contains lines of text with two columns - an IP address and a corresponding computer hostname. The columns can be separated by a space or a tab. The hosts file can be used to override DNS servers or provide hostname lookup in the absence of a DNS server.

Viewing and Editing the Hosts File

By default, the hosts file in Windows 11 doesn't contain any valid entries. All entries are commented out using the '#' symbol. To edit the hosts file:

  1. Click Start on the taskbar and type 'notepad'. Press ENTER.
  2. Press the Windows key (WIN) + E to open File Explorer.
  3. Paste the path %SystemRoot%\System32\drivers\etc\ in the 'Quick access' box and press ENTER.
  4. Drag the hosts file from File Explorer into the Notepad window.

NOTE: Only administrators can edit the hosts file in Windows, as it's located in a protected system directory.

There are two ways to edit the hosts file. The first method involves making a copy of the original file, editing it, and then replacing it. The second method uses the command line to append a line to the hosts file.

Method 1: Edit Hosts File using the GUI and Notepad

  1. Copy the hosts file and paste it to the desktop.
  2. Drag the hosts file from the desktop into a Notepad window.
  3. Add your entries at the bottom of the file.
  4. Save the file and close Notepad.
  5. Drag the hosts file from the desktop back to its original location, replacing the old file.

Method 2: Edit Hosts File using the Command Line

  1. Open the Start menu and type 'command'. Make sure Command Prompt is highlighted on the left, then click 'Run as administrator'.
  2. Give consent or provide an administrator username and password as prompted.
  3. Use the echo command to add a new entry to the hosts file. For example, echo 192.168.1.10 BOBPC >> %SystemRoot%\System32\drivers\etc\hosts.

Using either method, you'll be able to successfully edit the hosts file in Windows 11.

How Can We Help?
Our team thrives on new challenges. If you have a project in mind or simply want to ask a question, we’d love to hear from you.
Lumitiv is your all-in-one IT department with over 15 years on the job. We help simplify and guide businesses through the technical landscape, turning complex tech into a powerful business asset.
Copyright 2023 Lumitiv
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram