Technical Anshu
Tutorials Blog
🗂️ Hosts File Trap

One Website Will Not Open Because of a Hosts File Entry Check and Clean It

Every website opens except one. That one-name-only fingerprint almost always means something local is answering for that name before DNS is even asked — and that something is the hosts file. This page shows you how to prove it and clean it without breaking anything else.

✍️ Technical Anshu🪟 Windows 10 / 11⏱️ 7 minute read
🎥 Watch the full fix in the video above — every step shown live on a real Windows PC

The hosts file is a small text file from the earliest days of networking, and Windows still obeys it completely. Before your PC asks any DNS server about a name, it checks this file. If the name is listed, the address in the file is used and DNS is never consulted. That design is useful for testing, but it also means one leftover line can hijack or kill exactly one website on your machine while the rest of the internet works perfectly — the classic setup for a mystery ERR_NAME_NOT_RESOLVED that survives every normal DNS fix. Entries get there from old ad-blocking tricks, bundled software, cracks, well-meaning YouTube tweaks from years ago, and occasionally malware. The good news: the file is tiny, reading it takes a minute, and cleaning it is reversible if you back it up first.

Command Prompt — the fingerprint of a hosts file problem (example values)
C:\> ping shop-example.com Ping request could not find host shop-example.com. Please check the name and try again. C:\> nslookup shop-example.com Name: shop-example.com Address: 203.0.113.44 <-- DNS itself answers fine
👆 The proof pattern: ping uses the hosts file and fails, nslookup talks straight to DNS and succeeds. When you see this split, stop repairing DNS — the answer is sitting in a local file.
1

Why Ping and nslookup Disagree — and Why That Is the Proof

These two tools look identical in purpose and behave completely differently, and the difference is the whole diagnosis. ping resolves names the way your browser does: hosts file first, then DNS. nslookup ignores the hosts file entirely and asks the DNS server directly — it was built as a DNS debugging tool, not a connection tool.

So when nslookup happily returns an address for a name that ping and Chrome both reject, DNS has been proven healthy in one stroke. Something in the local resolution path — realistically the hosts file — is intercepting that one name. No server change, cache flush or router reboot can fix a file that is re-read on every single lookup.

2

Open the Hosts File and Read It Properly

The file lives at C:\Windows\System32\drivers\etc\hosts and has no extension — if you see a hosts.txt, that is a different, unused file someone created by accident. To read and later edit it:

  1. Open Notepad as administrator (right-click, Run as administrator)
  2. File, Open, paste the path above, and switch the file filter to All Files or you will not see it
  3. Lines starting with # are comments and harmless
  4. Active lines look like an address, a space, then a name — hunt for your failing site's name anywhere in the file

On a normal home PC the active part of this file is nearly empty. Long lists of names pointed at 127.0.0.1 or 0.0.0.0 mean a blocking tool or tweak populated it once — and your one failing site is probably in that list.

3

Back Up First, Then Clean Only What Is Guilty

Before editing a single character, copy the file to your desktop as a backup. If anything behaves oddly afterwards, restoring that copy returns you to exactly where you started. This ten-second habit is what makes the whole repair safe.

  1. Delete the line (or lines) naming your failing site — or put a # at the start of the line to disable it while keeping it visible
  2. Save the file, keeping it named exactly hosts with no extension — if Notepad insists on saving hosts.txt, your edit changed nothing and the real file is untouched
  3. Run ipconfig /flushdns so no cached copy of the bad answer survives
  4. Close and reopen the browser, then load the site

Do not delete the familiar localhost lines. And if the file contained names you never added and do not recognise, treat that as information: something on this PC edits system files. A full antivirus scan is the honest follow-up, not an optional extra.

4

When a Hosts Entry Is Legitimate — Do Not Delete Blindly

Honesty cuts both ways: not every entry is junk. Offices sometimes add lines for an internal server, developers add them to test a site before launch, and some old accounting or licence software genuinely depends on a name pinned to a local address. Delete another program's working entry and you trade one broken name for another.

The safe rule is narrow: touch only lines that name the site that is failing. If the failing name is your company's internal portal, stop — that entry may be the only thing making it reachable, and the real problem is the address it points to. That is a conversation for your IT person, armed with this page's ping-versus-nslookup proof, which will save them the first hour of guessing.

🔴 One more trap: Windows Defender and some antivirus tools watch this file, because malware loves editing it. If your cleaned entries mysteriously return within a day, something on the PC is rewriting the file — scan first, and only trust a hosts file that stays the way you left it.

🎥 Watch the Complete Fix Video

Watch the video for the live walkthrough — spotting the guilty entry, cleaning the file and proving the site opens again.

▶️ Watch Full Video
❓ Frequently Asked Questions

Where is the hosts file in Windows 10 and 11?

It is at C:\Windows\System32\drivers\etc\hosts, with no file extension. You must open it from an administrator Notepad to edit it, and the Open dialog needs its filter set to All Files before the file becomes visible.

How do I know the hosts file is my problem and not DNS?

Run ping and nslookup on the failing name. Ping follows the normal path including the hosts file, while nslookup asks DNS directly and ignores the file. If nslookup returns an address but ping says the host cannot be found, the hosts file is intercepting that name — DNS itself is healthy.

Is it safe to delete everything in the hosts file?

Delete only the lines naming your failing site, and keep a backup copy of the original file first. A typical home PC needs almost nothing in this file, but office software, developer setups and some licence tools do use deliberate entries, and removing those breaks other things.

This guide is based on the Technical Anshu ERR_NAME_NOT_RESOLVED fix video • Stuck on a step? Ask in the video comments — you will get a reply 🙏