The hosts file in Windows 10 dedicated servers is a plain text file used to map hostnames to IP addresses, allowing you to override DNS for specific domains. This is particularly useful for web development, testing, blocking websites, or redirecting domains locally.

Here’s a step-by-step guide on how to safely edit the hosts file on a Windows 10 machine.

What Is the Hosts File?

The hosts file is located at:

C:\Windows\System32\drivers\etc\hosts

Each entry in this file maps an IP address to a domain name, e.g.:

127.0.0.1 example.com

This forces the system to resolve example.com to the IP address 127.0.0.1 (localhost) instead of querying DNS servers.

Step-by-Step: Editing the Hosts File

Step 1: Open Notepad as Administrator

You must run a text editor with administrative privileges to edit the hosts file.

  1. Press Start, type notepad.

  2. Right-click Notepad, choose Run as administrator.

  3. If prompted by UAC (User Account Control), click Yes.

Step 2: Open the Hosts File

In Notepad:

  1. Click File > Open.

  2. Navigate to:

    C:\Windows\System32\drivers\etc\
  3. Change file type from “Text Documents (*.txt)” to “All Files“.

  4. Select hosts and click Open.

Step 3: Make Your Changes

Now, you can add or remove lines. Format:

IP_address domain_name

Examples:

  • Redirect domain to local machine:

    127.0.0.1 testsite.local
  • Point domain to a specific server:

    192.168.1.50 myapp.dev

To block a website:

127.0.0.1 facebook.com

⚠️ Each entry must be on a new line, and lines starting with # are treated as comments.

Step 4: Save and Exit

After editing:

  1. Click File > Save.

  2. Close Notepad.

The changes take effect immediately — no reboot required.

Tip: Test Your Hosts File Changes

Open Command Prompt and type:

ping yourdomain.com

It should show the IP you specified.

You can also test in the browser, or use ipconfig /flushdns to clear DNS cache if changes don’t reflect immediately.

Troubleshooting

  • Access Denied? Make sure you opened Notepad as an administrator.

  • Still seeing old IP? Run ipconfig /flushdns in the Command Prompt.

  • Antivirus conflict? Some security software may block changes to the hosts file — whitelist it if needed.

Use Cases

  • Preview websites before DNS propagation

  • Block distracting or malicious sites

  • Set up development or staging environments

  • Override DNS without modifying server settings