The Windows host file is a text file that tells your computer which websites go to which addresses, and it lives in a specific folder that Windows hides by default

Your computer uses the host file to redirect web addresses before it even asks the internet. When you type a website name into your browser, Windows checks the host file first — if it finds a match, it goes there instead of looking up the address online. This file sits on your hard drive, not on the internet, so it only affects your own computer.

The host file is useful when you want to block a website, test a website before it goes live, or prevent certain programs from connecting to their servers. Most people never need to touch it, but knowing where it is and how it works helps you understand what's happening if a website suddenly stops loading or if you're trying to troubleshoot a connection problem.

Key Takeaways

  • The Windows host file is located at C:\Windows\System32\drivers\etc\hosts on every Windows computer.
  • The file has no extension — it is named "hosts" with no .txt or .exe at the end, even though it is a text file you can edit.
  • Windows hides the etc folder by default, so you must show hidden files in File Explorer before you can see it.
  • Editing the host file requires administrator permission, and a single typo can break your internet connection to that website.
  • The host file takes effect when ready after you save it — you do not need to restart your computer.

How to find the host file in Windows 10 and Windows 11

Open File Explorer and navigate to C:\Windows\System32\drivers\etc. The quickest way is to click the address bar at the top, paste that path, and press Enter. If you see a folder called "etc" but no file called "hosts" inside it, Windows is hiding the file from view.

To show hidden files, click the View tab at the top of File Explorer, then check the box next to "Hidden items". The hosts file will now appear. It has no icon and no file extension — it is straightforward named "hosts". Do not confuse it with a folder or another file in that directory.

How to open and edit the host file safely

Right-click the hosts file and select "Open with", then choose Notepad. Do not double-click it — that may open it in a program that adds formatting you do not want. Notepad is the safest choice because it saves the file as plain text with no extra characters.

When you open the file, you will see lines that start with numbers and website addresses. Each line tells your computer to send a certain website to a certain address. For example, the line 127.0.0.1 localhost tells your computer that "localhost" means your own machine. Do not delete or change any existing lines unless you know exactly what you are doing.

After you make changes, click File, then Save. You will see a prompt asking for administrator permission — click Yes. If you do not see this prompt, you are not running Notepad as administrator, and your changes will not save. Close Notepad and try again, this time right-clicking Notepad itself and choosing "Run as administrator" before opening the file.

What happens when you add a line to the host file

Each new line you add follows the same format: an IP address, a space, and then a website address. For example, 127.0.0.1 example.com tells your computer that example.com lives at 127.0.0.1, which is your own computer. When you visit example.com in your browser, it will try to load from your machine instead of the real website.

This is useful for testing a website on your own computer before it goes live on the internet. It is also useful for blocking a website — if you point it to 0.0.0.0 or 127.0.0.1, your browser will not be able to reach the real site. However, this only works on your computer. Other devices on your network will not be affected.

The host file takes effect when ready after you save it. You do not need to restart your computer or your browser. If a website still loads normally after you add a line to the host file, check that you spelled the address correctly and that you saved the file with administrator permission.

Common mistakes that break your internet connection

The most common mistake is a typo in the website address. If you type 127.0.0.1 exampel.com instead of 127.0.0.1 example.com, your computer will block the misspelled version and the real website will load normally — but you will have wasted time. Always copy and paste website addresses from your browser to avoid this.

Another mistake is forgetting to save the file with administrator permission. If you edit the file in Notepad but do not see the administrator prompt when you save, your changes did not actually save. The file will look the same as before. Close Notepad without saving, right-click it, choose "Run as administrator", and try again.

A third mistake is accidentally deleting or changing the lines that were already in the file. The first few lines usually contain comments (they start with #) and important system entries. If you delete these, your computer may have trouble connecting to certain services. If you make a mistake, you can restore the original host file by opening Command Prompt as administrator and typing ipconfig /flushdns, then restarting your computer.

When you might need to edit the host file

Web developers use the host file to test a website on their own computer before uploading it to a real server. They point a domain name to their local machine so they can see how the site looks without publishing it to the internet.

Some people use the host file to block websites they want to avoid. By pointing a domain to a dead address, they prevent their browser from reaching it. This is less effective than using parental controls or browser extensions, but it works if you want a quick, manual block.

System administrators sometimes use the host file to redirect traffic on a network or to test internal services. If your company's IT department asks you to add a line to your host file, follow their instructions exactly and ask them to verify the change when you are done.

How to undo changes to the host file

If you added lines to the host file and want to remove them, open the file in Notepad again (as administrator), delete the lines you added, and save. Only delete the lines you know you added — leave the original system entries alone.

If you accidentally deleted or changed the original lines and your internet is now broken, you can restore the file. Open Command Prompt as administrator (right-click it and choose "Run as administrator"), type ipconfig /flushdns, and press Enter. This clears your computer's memory of the host file. Then restart your computer. If that does not fix the problem, you may need to restore the host file from a backup or contact your IT support.

Frequently Asked Questions

Can I edit the host file on a Mac or Linux computer?

Yes, but the location is different. On a Mac, the host file is at /etc/hosts. On Linux, it is also at /etc/hosts. You open it the same way — with a text editor like Nano or Vi — but you need administrator (sudo) permission to save changes. The format and behavior are identical to Windows.

Will editing the host file affect other people on my network?

No. The host file only affects your own computer. Other devices on your Wi-Fi or network will not see the changes you make. If you want to block a website for everyone on your network, you would need to change the settings on your router instead.

What is the difference between the host file and DNS?

The host file is checked first, before your computer asks a DNS server. DNS is the internet service that translates website names into addresses. If your host file has an entry for a website, your computer uses that instead of asking DNS. This is why the host file can override what DNS says.

Can a virus or malware change my host file?

Yes. Some malware edits the host file to redirect you to fake websites or block security software. If you notice websites loading from the wrong place or security programs not working, your host file may have been changed. Check it in Notepad and look for lines you did not add. If you find suspicious entries, delete them and run a full antivirus scan.

Do I need to restart my computer after editing the host file?

No. The changes take effect when ready after you save the file. Your browser may need to be closed and reopened to see the change, but your computer does not need to restart. If a website still loads normally after you edit the host file, clear your browser cache or try a different browser to rule out cached data.