How to Locate and Edit Hosts File on Windows (2024)

The hosts file lets you control and customize how your computer resolves domain names. Also, it is the first place Windows checks when connecting to a website. The best part is that you can block access to specific websites by editing the hosts file manually. In this article, we’ll walk you through the simple steps to locate and edit hosts file on Windows.

How to Locate and Edit Hosts File on Windows (1)

We recommend creating a copy of your hosts file to ensure you can return to the previous working state if something goes wrong. You can also create a restore point to create an extra layer of security. Before we go into more details, let’s find out what the hosts file is on Windows.

What Is a Hosts File on Windows

The hosts file is a local text file that maps hostnames to their corresponding IP addresses. This mapping allows you to override the default Domain Name System (DNS) settings for specific domains, enabling you to achieve various purposes like blocking unwanted websites, testing website changes before deploying them publicly, or redirecting websites to different IP addresses.

Normally, when your computer tries to access a website, it first checks the hosts file. If the hostname and its corresponding IP address are present, your computer directly connects to the website using that address. This bypasses the default DNS lookup process, which involves checking the DNS cache and contacting a DNS server if the address isn’t found in the cache.

How to Locate and Edit Hosts File on Windows (2)

However, if the hostname isn’t in the hosts file, your computer continues with the standard DNS lookup process. It checks the DNS cache, and if the address isn’t there, it contacts a DNS server to retrieve the IP address of the website’s server.

Let’s say you’re trying to open GuidingTech’s website. Your computer will directly connect to the website if you’ve previously added GuidingTech’s hostname and its IP address to your hosts file. It won’t waste time searching the DNS cache or contacting a DNS server.

However, if you haven’t added GuidingTech’s information to your hosts file, your computer will follow the standard DNS lookup process as described above.

Where Is the Hosts File Located in Windows

The host files are stored locally on your computer within the C drive. Below is the path to your hosts file:

Step 1:Press the Windows + S key on your keyboard. TypeThis PCand click Open.

How to Locate and Edit Hosts File on Windows (3)

Step 2:Double-click on Local Disk C.

How to Locate and Edit Hosts File on Windows (4)

Step 3:Navigate to the Windows folder.

How to Locate and Edit Hosts File on Windows (5)

Step 4:Scroll down and open the System32 folder.

How to Locate and Edit Hosts File on Windows (6)

Step 5:Search for the drivers folder and open it.

How to Locate and Edit Hosts File on Windows (7)

Step 6:Double-click on the etc folder.

How to Locate and Edit Hosts File on Windows (8)

Step 7:Now, you can see your hosts files.

How to Locate and Edit Hosts File on Windows (9)

Alternatively, you can also open This PC and paste the following in the address bar:

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

How to Edit Hosts File in Windows

Editing the hosts file in Windows is a straightforward process. To get started, you’ll need a text editor, and Windows conveniently includes Notepad as the default option.

However, if you prefer using other text editing tools, you can explore Notepad alternatives. To modify the hosts file, follow these steps:

Step 1:Click the Windows icon and select the search box. Enter Notepad and click Run as administrator. Select Yes when prompted.

How to Locate and Edit Hosts File on Windows (10)

Step 2:Click File and choose Open from the drop-down menu.

Tip:You can also press Ctrl + O to launch the Open menu directly.

How to Locate and Edit Hosts File on Windows (11)

Step 3:Paste the following in the address bar.

C:\Windows\System32\drivers\etc

Note:Switch the file type to All files instead of .txt, the default file type.

How to Locate and Edit Hosts File on Windows (12)

Step 4:Select the hosts file and click Open.

How to Locate and Edit Hosts File on Windows (13)

Step 5:Now, you can edit the host file. Once edited, click File and choose Save.

How to Locate and Edit Hosts File on Windows (14)

Also Read: How to fix Notepad not opening

Use of the Windows Hosts File

The Windows Hosts file is like a traffic cop for your computer’s internet connections. It has some useful jobs:

1. Blocking Websites

You can prevent access to unsolicited content and dangerous or distracting websites using the hosts file on your device. To accomplish this, add the below-mentioned file to your hosts file.

0.0.0.0 domainname.com
How to Locate and Edit Hosts File on Windows (15)

2. Redirecting Websites

Redirecting requests to a different IP address is another functionality the hosts file provides. This can be highly useful when creating a local testing environment or redirecting traffic away from malicious sites. To do so, add the following to your file:

127.0.0.1 domainname.com
How to Locate and Edit Hosts File on Windows (16)

3. Guarding Against Spam and Malware

Your system’s defenses can be strengthened by routinely updating the hosts file with the most recent listings of dangerous domains. You can manually block the suspicious and dangerous domains or reroute them to IP addresses that do not exist.

Modified Hosts File

If you followed the method mentioned above to locate and edit the hosts file on your Windows device but can still reach the sites you blocked or redirected using it, it could be due to DNS over HTTPS (DoH) being enabled in your browser.

DoH encrypts your DNS queries for privacy, allowing the browser to directly contact a secure DNS server and bypass the hosts file entirely, making it ineffective in blocking those websites. The new versions of popular browsers like Chrome, Firefox, and Edge come with DoH enabled by default. You must disable DoH in your browser settings to use the hosts file effectively.

Was this helpful?

Thanks for your feedback!

The article above may contain affiliate links which help support Guiding Tech. The content remains unbiased and authentic and will never affect our editorial integrity.

How to Locate and Edit Hosts File on Windows (2024)

References

Top Articles
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 6662

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.