# localhost resolved via DNS query on Windows7



## fluca1978 (Dec 13, 2011)

Hi,
I don't have a win7 machine to test (luckily), but seems that Microsoft thinks that _localhost_ is no more a valid name for your...ehm.. local host, so Win7 is now trying to resolve it via DNS due to an IPv4/IPv6 handling.
My comments to this could be quite rude...


----------



## SirDice (Dec 13, 2011)

There's no RFC that dictates localhost MUST be resolved locally. In this sense it's a hostname, just like all others.

Also note that you SHOULD add localhost to your DNS zones and resolve it correctly.


----------



## gkontos (Dec 13, 2011)

I was also looking for an RFC but I couldn't locate one. I agree that we shouldn't rely on hosts for resolution, still though I think that it is always good to have. Especially for localhost that should always resolve to 127.0.0.1 .

Regards


----------



## SirDice (Dec 13, 2011)

gkontos said:
			
		

> Especially for localhost that should always resolve to 127.0.0.1.


Not really. If you have an IPv6-only host this is going to cause problems. 
Which is also the reason why Microsoft removed localhost from the hosts file.


----------



## gkontos (Dec 13, 2011)

SirDice said:
			
		

> Not really. If you have an IPv6-only host this is going to cause problems.
> Which is also the reason why Microsoft removed localhost from the hosts file.



So you think that having no hosts file is better than using this ?


```
127.0.0.1	localhost
::1             localhost
```

Suppose that I need to bind an application to localhost only for security reasons. Is there any valid reason why I should use a DNS server instead of hosts ?

Regards


----------



## Anonymous (Dec 13, 2011)

SirDice said:
			
		

> There's no RFC that dictates localhost MUST be resolved locally. In this sense it's a hostname, just like all others.
> 
> Also note that you SHOULD add localhost to your DNS zones and resolve it correctly.



Chapter 4.1 of RFC 1912 supports your second statement, and given that, your first statement makes very much sense.


----------



## SirDice (Dec 14, 2011)

gkontos said:
			
		

> So you think that having no hosts file is better than using this ?
> 
> 
> ```
> ...


Which, again, will cause problems with an IPv6-only host.



> Suppose that I need to bind an application to localhost only for security reasons. Is there any valid reason why I should use a DNS server instead of hosts ?


I'm not saying there's _never_ a reason to use a hosts file, I'm saying I understand the reasoning not to supply one by default.


----------

