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.

I'm having some issues with my hosts file.

127.0.0.1 localhost
127.0.0.1 whatever
127.0.0.1 sub.localhost
127.0.0.1 example.com

localhost and whatever both work. However the others have weird behaviour.

Ping sub.localhost

c:\>ping sub.localhost
Pinging sub.localhost [127.0.0.1] with 32 bytes of data:

Ping example.com

C:\>ping example.com
Pinging example.com [127.0.0.1] with 32 bytes of data:

All seems ok, but browsing example.com will open the correct example.com page @ 192.0.32.10 which is not the expected behaviour... (obviously sub.localhost wont work at all)

Any ideas why this happens?

UPDATE 1: Removing Proxy Configuration from browser solved it for sub.localhost. example.com however still not working...

UPDATE 2: Some more info...

C:\Documents and Settings\amatos>ping example.com
Pinging example.com [127.0.0.1] with 32 bytes of data:

C:\Documents and Settings\amatos>ping www.example.com
Pinging www.example.com [127.0.0.1] with 32 bytes of data:

C:\Documents and Settings\amatos>nslookup example.com
Server:   ac1.-------.pt  (# suppose this is the router address...)
Address:  192.168.202.2

Non-authoritative answer:
Name:    example.com
Address:  192.0.32.10

Thanks to all that have tried to help so far!

share|improve this question
1  
What version of Windows are you on? –  Hello71 Aug 12 '10 at 15:53
    
hosts has 127.0.0.1 example.com and you say "browsing example.com, will open the correct example.com page @ 192.0.32.10 ", this doesn't sound right to me. –  bryan Aug 12 '10 at 16:03
    
Windows XP; @bryan, what exaclty doesn't sound right? –  acm Aug 12 '10 at 16:05
    
@acmatos: I'm with Bryan - you appear to want example.com to go to 127.0.0.1, yet you also say that when it goes to 192.0.32.10, that is 'correct'. Which do you actually want? –  boot13 Aug 12 '10 at 16:31
    
192.0.32.10 is the correct IP of example.com. By "correct" he means "registered in the normal DNS hierarchy". –  Andrew J. Brehm Aug 12 '10 at 16:36

5 Answers 5

up vote 3 down vote accepted

Is your Web browser using a proxy?

Mine is (I am at work) and when I connect to a Web site it seems to use the address the proxy server thinks, not the address my computer thinks.

share|improve this answer
    
Yes, I'm using an automatic proxy configuration. Shouldn't the host file be checked before the proxy?? Disabling the proxy will make sub.localhost work but not the example.com... One step in the right direction! :-) –  acm Aug 12 '10 at 16:58
    
The proxy works on a higher layer than the hosts file. Your browser never connects to the target, the proxy server does. –  Andrew J. Brehm Aug 12 '10 at 17:27
    
I will accept this answer because it was the most helpful and proxy issues are most likely to be causing my problem. Thanks. –  acm Aug 16 '10 at 10:55

You said example.com opens 192.0.32.10 - it should go to 127.0.0.1, so either you wrote wrong or the hosts file is not being applied correctly.

I am not sure about the example.com issue, but for the others, I would say that if ping is working, they are working fine, so simply double check that the webserver you are using has the host headers (or whatever setting on your server) set up correctly.

Edit -

Unsure why this is happening, First thing I would try is a different browser such as Firefox as this has it's own network settings which should not be affected by other system settings. If this solves it, then go back to IE and on the last tab (Advanced), choose Reset to remove anything else that may be setting this.

next, you can try tweaking your priorities of what is checked.

Open up the Registry Editor and navigate to :

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\ServiceProvider

Look for HostPriority and make sure it is a lower number than DNSPriority. You can also change it to a lower number such as 5 to make sure it takes priority over everything else.

If it still is not working, I would just say to check things such as your spelling, but it is hard without seeing the machine in person.

share|improve this answer
    
everything is well written... checked a million times. localhost as well as whatever are being correctly interpreted and both open 127.0.0.1, so I think it's safe to say hosts file is working, right? –  acm Aug 12 '10 at 16:35
    
@acmatos - You wrote "example.com will open the correct example.com page @ 192.0.32.10" - I am confused what you said correct page then? Also, have you tried flushing your dns settings and/or rebooting the machine? –  William Hilsum Aug 12 '10 at 16:48
    
Wil, I tried to clear that confusion in the original question coments. I tried both dns flush and reboot with no success... –  acm Aug 12 '10 at 16:54
    
@acmatos - updated. –  William Hilsum Aug 12 '10 at 17:36
    
Hello Wil, thanks for the effort however still no changes... I'll update OP with some more info. –  acm Aug 13 '10 at 8:24

Try opening a command line (cmd.exe) and do ipconfig /flushdns and then restart the browser.

Also, I just got to ask since it might be too obvious or sound too stupid. Have you tried rebooting (or at least logged out and then logged in)? I never cease being amazed at what problems this can solve.

share|improve this answer
    
Thanks, did both (dns flushing and reboot) already, however nothing changed. Had my faith on reboot also. :-) –  acm Aug 12 '10 at 16:39

UPDATE: Removing Proxy Configuration from browser solved it for sub.localhost. example.com however still not working...

Are you trying to visit www.example.com instead of example.com? There is a difference between both!

You should add www.example.com to the hosts file too if you want them both to forward to 127.0.0.1.

share|improve this answer
    
Agreeing with TomWij, also consider that your browser may automatically add the "www." prefix to "example.com" when you type it. So it's loading a different site from what you thought. –  CarlF Aug 12 '10 at 20:32
    
Nop, that's not the problem, both example.com and www.example.com have been added to hosts file and there are no changes. –  acm Aug 13 '10 at 8:14
    
Have you tried to use a different browser? This can help you to determine if it's only your browser or it is a system-wide problem. –  Tom Wijsman Aug 14 '10 at 9:34

Flush your ARP cache:

  1. Open a cmd window.
  2. arp -a will show all of your ARP entries.
  3. arp -d will delete the entries (or a specific one).

I would also flush the DNS entries:

ipconfig /flushdns
arp -d

ping <whatever>
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.