Pcornel
Browse topics
Options
Recent
Favorites
Windows · Technical reference

hosts File

Direct answer

The hosts file (C:\Windows\System32\drivers\etc\hosts) maps names to IP addresses locally and is checked before DNS. It is useful for testing, but forgotten entries are a common cause of odd name resolution.

When to use this

Use this when names resolve unexpectedly because of local overrides.

First 30 seconds

1. Get-Content C:\Windows\System32\drivers\etc\hosts.

2. Entry overriding DNS?

3. Malware often edits it — check for unexpected entries.

4. Edit as admin; flush cache.

5. Test resolution.

Operational verification

hosts entries loaded into the cache → override DNS

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common mistakes
  • Editing without administrator rights (file saves elsewhere or fails).
  • Saving as hosts.txt — Notepad adds the extension.
  • Entries forgotten after testing, breaking access later.
  • Malware adding entries to redirect sites — check the file when names resolve strangely.
  • Browsers using DNS over HTTPS may still honour the hosts file, but other apps with their own resolvers may not.
Platform / version applicability
Windows networking and network services
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformWindows networking and network services
Key commandipconfig /flushdns
Scope / prerequisiteUse this when names resolve unexpectedly because of local overrides.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Using the hosts file Narrow the fault
notepad C:\Windows\System32\drivers\etc\hosts      # run as administrator
10.0.0.50   app.example.com
ipconfig /flushdns
Resolve-DnsName app.example.com -CacheOnly

Documented example, not captured output. Entries are read before DNS. Malware abuses the hosts file to redirect or block security sites; Defender flags suspicious changes. Remove temporary entries after testing.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • The hosts file is checked before DNS.
  • Forgotten test entries cause odd resolution later.
  • Malware edits it to redirect sites.
Key checks
  • Resolve-DnsName <name> — resolve via the Windows resolver
  • Get-DnsClientServerAddress — DNS servers per interface
  • Get-DnsClientCache — resolver cache
  • Get-DnsClientGlobalSetting — suffix search list
  • Clear-DnsClientCache — flush the cache
ReferenceImportant terms & boundaries2 sections · depth on demand

Platform, version and operating-envelope scope

Windows DNS Client and Windows Server DNS where applicable; NRPT, DoH and interface behavior vary by release/policy.

In depth

The hosts file C:\Windows\System32\drivers\etc\hosts maps names to IPs before DNS is queried; entries are loaded into the DNS client cache.

Get-Content $env:windir\System32\drivers\etc\hosts
Add-Content $env:windir\System32\drivers\etc\hosts "`n10.0.10.50 test-app.corp.example.com"
Clear-DnsClientCache; Resolve-DnsName test-app.corp.example.com

Editing requires admin rights; Defender flags changes for common domains (hijacking). Forgotten hosts entries are a classic cause of "works on my machine" after server migrations — check the file early.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docWindows networking and network services current

Authoritative/upstream documentation reviewed for bounded claims in DNS Client → hosts File. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/windows-server/networking/dns/dns-client-settings · confidence 94%
Confirmation

Confirm action

Continue?