How do I refresh and clear all entries in hosts file on Windows Vista and 7?

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.

E. Pratik

Posted 2011-08-10T06:14:11.893

Reputation:

How do you know that that is what is causing the issue? – soandos – 2011-08-10T06:58:17.127

Answers

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.

surfasb

Posted 2011-08-10T06:14:11.893

Reputation: 21 453

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.

Sorean

Posted 2011-08-10T06:14:11.893

Reputation: 668

1DNS cache != the host file – soandos – 2011-08-10T06:57:43.180

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 – 2011-08-10T13:52:02.043

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.

Peter K.

Posted 2011-08-10T06:14:11.893

Reputation: 172

0

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

user956340

Posted 2011-08-10T06:14:11.893

Reputation: 1

0

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.

cornasdf

Posted 2011-08-10T06:14:11.893

Reputation: 101