Knowledgebase

A Guide To Locating & Editing a Host File in Windows 10

Have you ever wondered how your computer knows where to go when you type a website address?

The secret lies in a small but powerful file called the HOST FILE!

This file acts like a local map for your computer, helping it find websites quickly without always relying on the internet. Whether you are a beginner trying to understand how websites work or someone looking to block unwanted sites, knowing where to find and edit the host file in Windows 10 can be super useful.

Let’s dive in!

What is the Host File?

Before we dive into locating & editing a Host file, we need to understand about the Host File:

The host file is a plain text file in Windows that maps domain names (like www.example.com) to IP addresses. This helps your system find a website before checking with an external DNS server.


Also Read: How Can You Find The Location of the Windows Log Files?


What Does a Hosts File Contain?

A host file typically contains the following:

  •  Default Entries: Windows includes some default commented-out lines that provide guidance.
  •  Custom Mappings: Users can add their domain-to-IP mappings.
  •  Loopback Address: Most host files include 127.0.0.1 localhost, which refers to the local machine.


Also Read: How to Install MySQL Server in Windows?


Why Edit the Hosts File?

The big question is why you need to edit the Host File!

Here’s the answer:

  •  To Block Unwanted Websites: You can prevent access to certain sites by redirecting them to 127.0.0.1.
  •  To Test Websites Locally: You can redirect a domain to a local server before making it live.
  •  To Speed Up Domain Resolution, you can map a website locally, which can reduce lookup time if it is frequently visited.
  •  To Bypass DNS Restrictions: Sometimes, editing the host file can help access restricted sites.


Also Read: How to Launch Windows Internet Information (IIS) Manager?


Where is the Hosts File Located in Windows 10?

In Windows 10, the host file is located in the following directory:

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

This file does not have a file extension, so it may appear as just a host.


Also Read: How to Update SQL Server Management Studio?


How to Open the Hosts File?

Since the host file is a system file, you need administrative privileges to edit it.  Here’s how you can open it:

➔ Firstly, Press ‘WIN + S’ and type ‘Notepad.’

Search notepad

➔ After that, Right-click on Notepad and select ‘Run as administrator.’

notepad run as administrator

➔ In Notepad, you have to click ‘File’

click on file

➔ In that options, click ‘Open.’

Open file in notepad

➔ You have to navigate to the following directory:

C:\Windows\System32\drivers\etc\

➔ Change Text Documents (*.txt) to All Files in the bottom-right corner.

➔ Select the host file and click ‘Open.’


Also Read: How to Add a Subdomain in IIS Manager?


How to Edit the Hosts File?

➔ Once the host file opens, you can add new entries to redirect websites. The format is:

IP Address    Domain Name

➔ For example, if you want to redirect Facebook website to your local machine (to block access), you can add:

127.0.0.1    www.facebook.com

➔ Similarly, if you are a developer and testing a website on your local server (e.g., at IP 192.168.1.100), you can map a custom domain:

192.168.1.100    yourtestsite.local

When you type yourtestsite.local in your browser, it will load from 192.168.1.100 instead of going to an actual internet location.

How to Save the Hosts File?

➔ After making changes, You have to click ‘File’ & then choose the option ‘Save.’

➔ Once the file is saved, close Notepad.

➔ Now, just restart your browser or computer for changes to take effect.


Also Read: How to Check Users Logged in Remote Desktop?


What Happens When You Modify a Host File?

Modifying the host file impacts how your computer resolves domain names. Here’s what happens:

  •  Immediate Changes: Unlike DNS updates, changes made in the host file take effect instantly.
  •  Overrides External DNS: If your domain is listed in the host file, your system won’t query an external DNS server for it.
  •  Local Redirection: You can easily redirect domains to a local IP for testing or blocking purposes.


Also Read: How to Change Password on Remote Desktop?


Common Issues Users Generally Face & Fixes For That

Cannot Save the File?

You need to ensure that you have opened Notepad as an administrator.

Changes Not Taking Effect?

Try flushing the DNS cache by opening Command Prompt as an administrator and running:

ipconfig /flushdns

Antivirus Blocking Changes?

Some antivirus programs prevent modifications to the host file. You have to temporarily disable protection or whitelist the file in your security software settings.


Also Read: How to check Reboot and Shutdown logs in Windows server?


Conclusion

The host file may be small, but it plays a big role in managing website access on your computer. Whether you need to block sites, speed up access to frequently visited websites, or test new domains, understanding how to find and edit this file can be a game-changer. 

Now that you know where the host file is and how to modify it, you’re one step closer to becoming a Windows pro! Using this knowledge, you can better control your internet access, improve website testing, and enhance your overall browsing experience.

Frequent-Server-Downtime
Don’t Frustrate With Unreliable VPS

Migrate to reliable hosting that fulfils your requirements!