How to locate and edit your hosts file in Windows 10

In this tutorial, you will learn how to locate and edit your hosts file in Windows 10. The hosts file in Windows 10 is a local file used to map hostnames (like example.com) to IP addresses. Editing this file can help you block websites, test domain redirections, or troubleshoot DNS issues.

Firstly, let’s locate the Hosts File.
The Path is as follows:
C:\Windows\System32\drivers\etc\hosts

Important notes before editing:

  • You must have admin privileges to edit the file.
  • Always create a backup of the original hosts file before making changes.
  • Use a plain text editor like Notepad (not Word or WordPad).

To edit the hosts file in Windows 10, follow the steps:

  1. To open Notepad as Administrator, click Start, search for Notepad, right-click it, and select Run as administrator.
    Run as administrator - Windows10
  2. Open the Hosts File:
    1. In Notepad, go to File > Open.
    2. Navigate to:
      C:\Windows\System32\drivers\etc
    3. Change the file type from Text Documents (.txt) to All Files (.).
    4. Select the file named hosts and click Open.
  3. Add or Modify Entries:
    1. To redirect a domain to an IP address, add a line like:
      0.0.1 example.com

      Each entry should be on a new line. Use the format:

      [IP Address] [Domain Name]
  4. Save the File:
    1. Press Ctrl + S to save your changes.
    2. Close Notepad.
  5. Practical Use Cases:
    1. Block a website
      Add the following entry to prevent access to a specific site:

      0.0.1 facebook.com
    2. Test a domain setup
      Redirect a domain to a staging server by entering:

      168.1.50 staging.example.com
    3. Redirect a domain
      Force a domain to resolve to your local machine:

      0.0.1 example.com
  6. Some important instructions:
    1. Changes take effect immediately, no reboot needed.
    2. You may just need to flush the DNS cache:
    3. Open Command Prompt and run:
      ipconfig /flushdns

In such a manner, you can locate and edit your hosts file in Windows 10. For more such informative articles, do visit our KB section, and for help, contact our support specialists.

Read more knowledge base about How to Edit the Hosts File in Windows, macOS, and Linux

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

How Can I Find the Private Key for SSL Certificate?

How Can I Find the Private Key for SSL Certificate?

An SSL certificate works with a private key to secure communication between a server and…

WHat is port 443

What Is Port 443? How HTTPS Secures Web Traffic

When you open a website that starts with https://, your browser uses a network port…

Dual-Booting Linux with Windows – Points to Note

Windows isn’t the only free operating system you can install on your computer. You can…