Skip to content

How-ToOS

How to Edit (and Reset) the Hosts File in Windows 11

The Windows 11 hosts file, at C:\Windows\System32\drivers\etc\hosts, maps hostnames to IP addresses before your PC asks a DNS server. Edit it with Notepad running as administrator to name devices on your network or block a site, flush the DNS cache afterwards, and use Microsoft's steps to reset it to the default if it causes connection problems.

By , Systems & Technical Editor

4 min read

How to Edit (and Reset) the Hosts File in Windows 11

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:

  1. Press the Windows key and type Notepad.

  2. Right-click Notepad and choose Run as administrator, then click Yes at the User Account Control prompt.

  3. In Notepad, choose File > Open and go to C:\Windows\System32\drivers\etc.

  4. Change the file type drop-down from Text documents (*.txt) to All files (*.*) so the hosts file appears, then open hosts.

  5. 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:

  1. Open Notepad and paste in Microsoft's default text, which is reproduced at the end of this section.

  2. 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.

  3. Go to %WinDir%\System32\drivers\etc, right-click the existing hosts file, choose Rename and call it hosts.old.

  4. Copy the new hosts file from your desktop into that folder, approving the administrator prompt.

  5. 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?

You want to...

Best tool

Name a device on your network, or block a site on one PC

Hosts file

Change who answers lookups for the whole PC

Change your DNS server

Stop a particular app from going online

Block it in Windows Firewall

Fix lag, rather than a site that won't load

Fix high ping and packet loss

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.

The bottom line

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.

Sources

  1. 01Microsoft Support: How to reset the Hosts file back to the default
  2. 02Microsoft Learn: ipconfig
  3. 03Epic Games Technical Support: How do I reset my Windows Hosts file back to default?

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

DirectX 11 vs DirectX 12 vs Vulkan: Which Should You Pick in Games?

Versus

DirectX 11 vs DirectX 12 vs Vulkan: Which Should You Pick in Games?

DirectX 12 and Vulkan are lower-level graphics APIs designed to cut CPU overhead and scale across more CPU cores, and DirectX 12 unlocks features such as ray tracing and the DirectX 12 Ultimate set. DirectX 11 is older and more driver-managed but remains a useful fallback for older GPUs or when a DX12 mode misbehaves. Vulkan is cross-platform and key on Linux. Start with the game's default.

Callum Reid6 min

How to Fix Missing DLL Errors in Windows 11 (VCRUNTIME140, MSVCP140 and More)

How-To

How to Fix Missing DLL Errors in Windows 11 (VCRUNTIME140, MSVCP140 and More)

Most "DLL was not found" errors in Windows 11 mean a program needs a Microsoft runtime that isn't installed. Install the latest Visual C++ v14 Redistributable (x64 and x86) for VCRUNTIME140 and MSVCP140 errors, older Visual C++ packages for 120, 110 or 100 files, and the DirectX End-User Runtime for d3dx9 or xinput1_3 errors. Then verify game files or run DISM and SFC. Avoid DLL download sites.

Marcus Thorne7 min

inferzero Pushes Intel Arc A770 Past 1,700 Tokens/s in Prompt Processing

News

inferzero Pushes Intel Arc A770 Past 1,700 Tokens/s in Prompt Processing

inferzero, an independent open-source LLM engine for Intel Arc graphics, now reports more than 1,700 tokens per second of prompt processing on an Arc A770 16GB with a 27B model, according to contributor results reported by Joho no Todai. We cover what it is and what the numbers mean.

Eleanor Shaw4 min