Use this when names resolve unexpectedly because of local overrides.
hosts File
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.
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.
hosts entries loaded into the cache → override DNS
Context & applicabilityCommon mistakes · platform/version boundaries
- 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.
Operational reference
Fast context before you go deeper.
ipconfig /flushdnsVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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 · 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.
- The hosts file is checked before DNS.
- Forgotten test entries cause odd resolution later.
- Malware edits it to redirect sites.
Resolve-DnsName <name>— resolve via the Windows resolverGet-DnsClientServerAddress— DNS servers per interfaceGet-DnsClientCache— resolver cacheGet-DnsClientGlobalSetting— suffix search listClear-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.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
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%