how to edit hosts file windows 10

Mastering Windows 10: A Quick Guide to Editing Your Hosts File

By Jessica Davis
AD

The Windows hosts file is a crucial yet often overlooked component of your system's network settings. It's a plain-text file that maps hostnames to IP addresses, providing a way to redirect your domain requests to specific IP addresses. Editing this file can help you block websites, speed up your internet, or even improve game performance. Here's a comprehensive guide on how to edit the hosts file on Windows 10.

Before we dive into the steps, let's understand why you might want to edit your hosts file. You can use it to resolve common issues like DNS hijacking, or to block malicious websites, intrusive ads, or even enhance your gaming experience by tweaking game server connections. So, without further ado, let's get started.

Understanding the Windows 10 Hosts File

The hosts file in Windows 10 is located at:

AD
How To Edit Your Hosts File In Windows 10
How To Edit Your Hosts File In Windows 10
How to Edit Hosts File in Windows 10 [Quickly & Easily] - MiniTool Partition Wizard
How to Edit Hosts File in Windows 10 [Quickly & Easily] - MiniTool Partition Wizard
Access Denied When Editing Hosts File in Windows 11/10
Access Denied When Editing Hosts File in Windows 11/10

C:\Windows\System32\Drivers\etc\hosts

It's a plain-text file, so you can open it in any text editor. However, it's hidden by default, so you'll need to follow a few extra steps to access it. Let's see how you can do that.

How to Edit the Hosts File in Windows 10
How to Edit the Hosts File in Windows 10
How to Edit the Hosts File in Windows 10
How to Edit the Hosts File in Windows 10

Accessing the Hosts File

To access the hosts file, you'll need to use the Notepad app with administrator privileges. Here's how:

  1. Press Win + S on your keyboard to open the Search bar.
  2. Type notepad and press Ctrl + Shift + Enter to open Notepad as an administrator.

Once you've opened Notepad as an administrator, follow these steps to open the hosts file:

AD
  1. Click on File in the menu, then Open...
  2. In the 'File name' field, type C:\Windows\System32\Drivers\etc\hosts, and select 'All Files (*.*)' from the drop-down menu.
  3. Click Open.

Understanding the Hosts File Syntax

The hosts file consists of IP addresses and hostnames, separated by a space or tab, in the following format:

IP Address Hostname

The first column represents the IP address, and the second column is the hostname. For example:

AD

127.0.0.1 localhost

This line tells your system to redirect any requests for 'localhost' to the IP address 127.0.0.1.

Editing the Hosts File

Now that you've accessed the hosts file with Notepad, let's dive into the editing process.

AD

Adding an Entry

To add an entry, simply type the IP address, a space or tab, and the hostname, each on a new line. For example, to block a website like 'example.com', add the following line:

127.0.0.1 example.com

This will redirect any requests for 'example.com' to the loopback address 127.0.0.1, effectively blocking it.

Removing an Entry

To remove an entry, simply highlight the corresponding line and press Delete on your keyboard.

Saving and Closing the File

Once you've made your changes, click on File in the menu, then Save. You'll be prompted to confirm that you want to save the changes to the hosts file. Click Yes to proceed.

After saving, close the Notepad window. You might need to reboot your system for the changes to take effect. However, sometimes, Windows might cache the old hosts file. If you're still facing issues, try clearing your DNS cache with the following command in Command Prompt:

ipconfig /flushdns

That's it! You've now successfully edited your Windows 10 hosts file. Remember, editing the hosts file can have significant impacts on your system's network behavior, so always exercise caution and back up your original file before making any changes.

Now that you're comfortable with editing the hosts file, why not explore other ways to optimize your Windows 10 system? Happy tweaking!

AD