Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from serverfault.com Aug 10 '11 at 6:18

This question came from our site for professional system and network administrators.

    
How do you know that that is what is causing the issue? –  soandos Aug 10 '11 at 6:58

4 Answers 4

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.

share|improve this answer
    
DNS cache != the host file –  soandos Aug 10 '11 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. –  JKM Aug 10 '11 at 13:52

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.