It's based on Microsoft's support and command-line documentation, plus Epic Games' support guidance, all checked on 25 November 2026.
The hosts file is a long-standing part of Windows networking, and Windows 11 still uses it. It's a plain text file that matches names, such as a website address, to IP addresses. Because Windows checks it before asking a DNS server, an entry in it overrides the internet's normal lookups. That makes it handy for a few jobs, and a common culprit when one site or game server mysteriously won't connect.
What the hosts file is for
Microsoft describes the hosts file as a plain-text system file that maps human-friendly hostnames to IP addresses. Each entry goes on its own line: an IP address, then one or more hostnames, separated by spaces or tabs. Lines starting with a hash (#) are comments, and Windows ignores blank lines.
Typical home uses include:
Giving a device on your network a name, such as pointing nas.home at your NAS's local IP address, so you don't have to remember the number.
Blocking a site on one PC, by pointing its name at your own computer (127.0.0.1) so it can't connect to the real server.
Testing, such as pointing a website's name at a new server's IP address on your PC only, before its public DNS record changes.
It's also why the hosts file turns up in troubleshooting guides. Microsoft warns that a modified hosts file can override normal name resolution and cause connection problems. Epic Games' support site suggests resetting it if you're having connection issues with its services.
Where to find it
The hosts file lives in %WinDir%\System32\drivers\etc, which on most PCs is C:\Windows\System32\drivers\etc. The file is simply called hosts. Microsoft notes that a hosts file can't have a file extension, so make sure yours hasn't been saved as hosts.txt.
Changing files in this folder needs administrator permission. Microsoft's own steps include an administrator prompt when you copy a new hosts file into it.
How to edit the hosts file
The simplest way is to open Notepad with admin rights:
Press the Windows key and type Notepad.
Right-click Notepad and choose Run as administrator, then click Yes at the User Account Control prompt.
In Notepad, choose File > Open and go to C:\Windows\System32\drivers\etc.
Change the file type drop-down from Text documents (*.txt) to All files (*.*) so the hosts file appears, then open hosts.
Add your entries at the bottom, one per line, and save.
Before you change anything, save a copy of the original somewhere safe, such as your desktop, so you can undo your edits.
Example entries
192.168.1.50 nas.home
127.0.0.1 example.com
127.0.0.1 www.example.com
The first line sends nas.home to a device on your local network. The other two point example.com at your own PC, which blocks it in practice. A name and its www. version are different hostnames, so if you want to block both you need a line for each.
Can't save? Use Microsoft's method instead
If Notepad won't save the file, use Microsoft's approach: save your edited copy as hosts on the desktop, with Save as type set to All files (*.*) and the name typed in quotes so Notepad doesn't add .txt. Then rename the existing file in C:\Windows\System32\drivers\etc to hosts.old and copy your new one into the folder, approving the administrator prompt.
Make the change take effect
Windows keeps recent lookups in its DNS cache. Microsoft's ipconfig documentation says that cache includes entries preloaded from the hosts file, and that the DNS Client service uses it before asking your configured DNS servers. To clear old results after editing hosts, open Terminal or Command Prompt and run:
ipconfig /flushdns
You can check what Windows has cached, including hosts file entries, with ipconfig /displaydns. Our guide to flushing the DNS cache has more detail. If a change still doesn't seem to work, close and reopen your browser and try again.
How to reset the hosts file to the default
If you suspect the hosts file is behind a connection problem, or you just want a clean start, Microsoft's reset is straightforward:
Open Notepad and paste in Microsoft's default text, which is reproduced at the end of this section.
Choose File > Save as, type "hosts" (with the quotes) as the file name, set Save as type to All files (*.*) and save it to your desktop.
Go to %WinDir%\System32\drivers\etc, right-click the existing hosts file, choose Rename and call it hosts.old.
Copy the new hosts file from your desktop into that folder, approving the administrator prompt.
Run ipconfig /flushdns.
Every line of Microsoft's default file is a comment, so it has no active entries. It ends with these lines:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
Keeping hosts.old means you can check what was in there afterwards. If you find entries you didn't add, especially ones pointing well-known sites at unfamiliar addresses, it's worth running a Microsoft Defender Offline scan.
Hosts file, DNS or firewall: which do you need?
Our verdict
The Windows 11 hosts file is a simple, built-in way to name devices on your network or block a site on one PC, and it's often worth checking when one site or game service won't connect. It lives at C:\Windows\System32\drivers\etc\hosts, needs administrator rights to edit and has no file extension. Keep a backup before editing, flush the DNS cache afterwards, and use Microsoft's reset steps if anything goes wrong.