{"id":1053,"date":"2026-11-06T22:21:53","date_gmt":"2026-11-06T22:21:53","guid":{"rendered":"https:\/\/windows-vps.org\/blog\/?p=1053"},"modified":"2026-11-06T22:21:53","modified_gmt":"2026-11-06T22:21:53","slug":"windows-server-hosts-file-dns-cache-troubleshooting","status":"publish","type":"post","link":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/","title":{"rendered":"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><code>Resolve-DnsName www.example.com<\/code> returns 198.51.100.10, the browser opens a site from 2019, and the provider&#8217;s control panel insists the A record was changed an hour ago. In that situation one of two things is lying: a line in <code>C:\\Windows\\System32\\drivers\\etc\\hosts<\/code> or a stale entry in the DNS Client cache. Both are local, both override DNS in ways people forget, and both produce exactly the &#8220;wrong site \/ old IP&#8221; bug that gets escalated to the network team. If you are standing up a fresh host to test this, see <a href=\"https:\/\/windows-vps.org\/\">Windows VPS plans with RDP included<\/a> and work through the sequence below on the box that shows the fault.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Read the hosts file before you blame DNS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The hosts file is checked before any DNS query is sent, and only the first matching line for a name is used. Read it raw, because explorer hides it and the extensionless filename breaks naive editors: <code>Get-Content C:\\Windows\\System32\\drivers\\etc\\hosts | Where-Object { $_ -notmatch '^\\s*#' -and $_.Trim() }<\/code>. Anything listed there wins over both the resolver and your new A record.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common surprises: a migration script that pinned the old server, a line with the hostname in a comment position that still parses, and an entry with tabs instead of spaces that some tools accept and others ignore. Check the file timestamp with <code>(Get-Item C:\\Windows\\System32\\drivers\\etc\\hosts).LastWriteTime<\/code>; a recent date on a server nobody admits to changing is a strong signal.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Confirm the client is actually using the entry<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ping www.example.com<\/code> resolves the hosts entry and labels it: the reply line includes <code>[198.51.100.10]<\/code>, and when the name came from the hosts file the resolution note shows the address as a literal rather than a resolved name. Compare with <code>Resolve-DnsName www.example.com -DnsOnly<\/code>, which bypasses the client cache and the hosts file for the query itself, giving you the authoritative answer from the DNS server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>Resolve-DnsName -DnsOnly<\/code> gives the correct IP and the browser still loads the old one, the hosts file or the cache is the culprit and the DNS server is exonerated. If both give the old IP, the problem is upstream \u2014 a stale record on a secondary zone, a caching forwarder, or a public resolver still holding the pre-change TTL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Flush the cache and understand what flush does not do<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ipconfig \/flushdns<\/code> clears the client resolver cache, then <code>ipconfig \/displaydns<\/code> should show no entry for the name. Note that flush does not touch the hosts file, does not clear the browser&#8217;s own cache, and does not clear the DNS server&#8217;s cache. Chrome and Edge keep their own resolution cache; restart the browser or open an InPrivate window to rule them out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On a server acting as a DNS server itself, also clear the server cache: <code>Clear-DnsServerCache -Force<\/code> in PowerShell, or <code>dnscmd \/clearcache<\/code>. If the host forwards to a public resolver, that resolver may still hold the old record until TTL expiry \u2014 check the TTL on the current record with <code>Resolve-DnsName name -Type A | Select-Object Name,IPAddress,TTL<\/code> before assuming anything is broken locally.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">DNS suffix search order decides which name you actually asked for<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An unqualified name like <code>intranet<\/code> is appended with each suffix in turn until one resolves. When the machine&#8217;s primary DNS suffix is <code>corp.example.com<\/code> but the record you want lives in <code>example.com<\/code>, you can reach the wrong host entirely. Inspect the order with <code>Get-DnsClientGlobalSetting | Select-Object SuffixSearchList<\/code> and the per-interface suffix with <code>Get-DnsClient | Select-Object InterfaceAlias,DnsSuffix,ConnectionSpecificSuffix<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The per-interface suffix is appended first, then the global list, then the primary suffix. In a multi-homed VPS with a secondary NIC left at default, that ordering changes without anyone editing DNS. Fix it with <code>Set-DnsClientServerAddress<\/code> per interface and <code>Set-DnsClientGlobalSetting -SuffixSearchList<\/code> when you need an explicit order, then re-test with the FQDN to confirm the short name was the problem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rule out the other local override: NetBIOS and LLMNR<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Short names can also resolve through LLMNR or NetBIOS, neither of which appears in <code>ipconfig \/displaydns<\/code> output the way DNS entries do. A stray machine on the same subnet answering to the name will beat DNS for a short-name lookup. Test by disabling LLMNR on the client (<code>HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows NT\\DNSClient<\/code>, <code>EnableMulticast=0<\/code>) and retrying \u2014 if the answer changes, you were never talking to DNS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Internet-facing names this is rarely the issue; for internal names on a Windows VPS with a flat network it is common. <code>nslookup name<\/code> bypasses much of the client stack and will return the DNS answer, which makes it a useful contrast against <code>ping<\/code> and against what the application actually connected to.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prove the fix from the application, not the shell<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A corrected hosts file and an empty cache still leave the application layer. For IIS, check that the site binding host header matches the name being requested, and that no HTTP redirect rule in <code>web.config<\/code> points at the old hostname. For .NET, a hard-coded base URL in <code>appsettings.json<\/code> survives every DNS fix you make.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Confirm with a request that shows the peer: <code>Test-NetConnection www.example.com -Port 443<\/code> prints <code>RemoteAddress<\/code>, and <code>curl.exe -v https:\/\/www.example.com\/ -o NUL<\/code> shows the resolved IP followed by the SNI name. If the resolved IP is right but the certificate name is wrong, you are hitting the new server on an old binding \u2014 an IIS problem, not a resolver problem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Keep a short, auditable workflow<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The sequence that closes these tickets fastest: read the hosts file, run <code>ipconfig \/displaydns<\/code> and grep for the name, run <code>Resolve-DnsName -DnsOnly<\/code>, compare the three answers, then fix whichever layer disagreed. Document any deliberate hosts entry next to it in the file itself, so the next admin does not delete it or spend an hour on a stale one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On recurring &#8220;wrong site&#8221; reports, the hosts file is usually the result of an old migration and the cache is a symptom of a short TTL, not a bug. Review <a href=\"https:\/\/windows-vps.org\/\">the full Windows Server specs and pricing<\/a> if you are replacing host that has accumulated years of them, and rebuild with a clean resolver configuration.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Read the hosts file, flush and inspect the DNS client cache, and check DNS suffix search order to prove which layer is returning a stale or incorrect IP.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1053","post","type-post","status-publish","format-standard","hentry","category-tutorials-guides"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs - Windows VPS Blog<\/title>\n<meta name=\"description\" content=\"Read the hosts file, flush and inspect the DNS client cache, and check DNS suffix search order to prove which layer is returning a stale or incorrect IP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs\" \/>\n<meta property=\"og:description\" content=\"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs\" \/>\n<meta property=\"og:url\" content=\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/\" \/>\n<meta property=\"og:site_name\" content=\"Windows VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-06T22:21:53+00:00\" \/>\n<meta name=\"author\" content=\"windows-vps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@myxiechengxuan\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"windows-vps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/\",\"url\":\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/\",\"name\":\"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs - Windows VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\"},\"datePublished\":\"2026-11-06T22:21:53+00:00\",\"author\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\"},\"description\":\"Read the hosts file, flush and inspect the DNS client cache, and check DNS suffix search order to prove which layer is returning a stale or incorrect IP.\",\"breadcrumb\":{\"@id\":\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/windows-vps.org\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#website\",\"url\":\"https:\/\/windows-vps.org\/blog\/\",\"name\":\"Windows VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/windows-vps.org\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58\",\"name\":\"windows-vps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g\",\"caption\":\"windows-vps\"},\"sameAs\":[\"https:\/\/windows-vps.org\/blog\",\"https:\/\/x.com\/myxiechengxuan\"],\"url\":\"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs - Windows VPS Blog","description":"Read the hosts file, flush and inspect the DNS client cache, and check DNS suffix search order to prove which layer is returning a stale or incorrect IP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/","og_locale":"en_US","og_type":"article","og_title":"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs","og_description":"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs","og_url":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/","og_site_name":"Windows VPS Blog","article_published_time":"2026-11-06T22:21:53+00:00","author":"windows-vps","twitter_card":"summary_large_image","twitter_creator":"@myxiechengxuan","twitter_misc":{"Written by":"windows-vps","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/","url":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/","name":"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs - Windows VPS Blog","isPartOf":{"@id":"https:\/\/windows-vps.org\/blog\/#website"},"datePublished":"2026-11-06T22:21:53+00:00","author":{"@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58"},"description":"Read the hosts file, flush and inspect the DNS client cache, and check DNS suffix search order to prove which layer is returning a stale or incorrect IP.","breadcrumb":{"@id":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/windows-vps.org\/blog\/windows-server-hosts-file-dns-cache-troubleshooting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/windows-vps.org\/blog\/"},{"@type":"ListItem","position":2,"name":"Windows Hosts File and DNS Client Cache: Hunting Wrong-Site and Old-IP Bugs"}]},{"@type":"WebSite","@id":"https:\/\/windows-vps.org\/blog\/#website","url":"https:\/\/windows-vps.org\/blog\/","name":"Windows VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/windows-vps.org\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/44caceed916d0db318aa08d5623a7a58","name":"windows-vps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/windows-vps.org\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f2573db5afcd1a6ab9abcc5d48fc8e42584bc87ab9d98cc156e5b2097766dd9?s=96&d=mm&r=g","caption":"windows-vps"},"sameAs":["https:\/\/windows-vps.org\/blog","https:\/\/x.com\/myxiechengxuan"],"url":"https:\/\/windows-vps.org\/blog\/author\/myxiechengxuan\/"}]}},"_links":{"self":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/comments?post=1053"}],"version-history":[{"count":1,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1053\/revisions"}],"predecessor-version":[{"id":1054,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/posts\/1053\/revisions\/1054"}],"wp:attachment":[{"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/media?parent=1053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/categories?post=1053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/windows-vps.org\/blog\/wp-json\/wp\/v2\/tags?post=1053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}