2

A website is not opening on my PC which was accessible a week ago.

I don't know how to delete the wrong entries in the hosts files. Is it possible to clear all the entries in the hosts file? I'm looking for a solution for Windows Vista and 7.

1
  • How do you know that that is what is causing the issue?
    – soandos
    Aug 10, 2011 at 6:58

5 Answers 5

2

ipconfig is the wrong way to go at this. This only clears the resolver's cache.

The host file is a text file located, I think, in %windir%\system\drivers\etc.

You'll have to fire up an elevated Notepad to edit the entries, if somehow they were changed without your knowledge.

To start up notepad elevated, hit the Window key and type notepad. Then press CTRL+ Shift+ ENTER. A UAC prompt will appear. Navigate to the host file and open it up. If it contains a lot of weird entries, you could be infected with malware.

I'd backup your data and clear the disk. There is no telling what else may be spying on your data. Then find yourself a good antivirus( I recommend Microsoft's Security Essentials) and use Chrome for browsing insecure sites.

1

The easiest way is to empty your dnscache.

  • Open up a command prompt.
  • Type in "ipconfig /flushdns" without the quotes.

That will force it to refresh the computers DNS cache. If your PC is connected to a router and using the router as a DNS resolver, you may need to power off that device for 5 minutes as well as the modem connected to it to allow it to fully reset and power them back up.

2
  • 1
    DNS cache != the host file
    – soandos
    Aug 10, 2011 at 6:57
  • Based on the original context of the question (which has now been changed) he said that he was having issues connecting to websites. Which as most of us would understand is not related to his hosts file. And yes I do understand that DNSchace != host file. It just seemed unlikely that a user would have multiple websites hardcoded into their hosts file for public webpages.
    – Sorean
    Aug 10, 2011 at 13:52
1

If you have hard-coded the IP address of the website in your hosts file, then you may need to hand-edit the file (usually called) C:\Windows\System32\drivers\etc\hosts. Find the entry in that file related to the website, and insert a hash/pound/number sign (#) at the beginning of that line.

1

An empty file at %windir%\system32\drivers\etc\hosts will mean an empty hosts file. If you look at the default file, all the lines are commented out (lines start with #). If you really want to clear your hosts file, either fire it up in Notepad and clear everything that doesn't start with a # or run this from an elevated Command Prompt:

echo. 2> %windir%\system32\drivers\etc\hosts

If you want to clean out specific entries you can use Notepad or findstr /V to strip the entries and rewrite to the file.

0

once your lmhosts and hosts files are correct, go to elevated dos prompt and try "ipconfig /flushdns" and "nbtstat -R"

You must log in to answer this question.