2

I discovered recently that Windows 7 (probably other versions too) shows no longer "localhost", but the computer name (with domain), when resolving the IP address 127.0.0.1 or ::1.

The strange thing is, that this still occurs, if I add this mapping explicitly to the hosts file, e.g.

127.0.0.1 localhost

If I use any other name, e.g. "localhostv4", the name is used. Only "localhost" is replaced by the computer name.

Does anyone know why this is happen, and since when? We discovered it recently because we had some functionality depending on it and got a bug report recently and traced it down to this behaviour.

Andreas Mueller
  • 201
  • 4
  • 13
  • It's probably not Windows. Which HTTP server are you using? – Catalyst Jul 06 '17 at 16:30
  • It has nothing to do with HTTP. You can see it e.g. with netstat (Foreign Address column) or Resource Monitor or with `ping localhost`. – Andreas Mueller Jul 06 '17 at 16:42
  • Does it happen with 3rd-party tools or only in-box Windows tools? – Anders Jul 06 '17 at 17:36
  • I don't think this is (particularly) new behaviour, and I believe it is as-intended. Why is it a problem? – Harry Johnston Jul 06 '17 at 22:28
  • I know the behaviour has changed and I find this behaviour at least a little bit strange. And I found this not documented anywhere yet. I think if I have DNS set up properly in a way that 127.0.0.1 is mapped to localhost, the reverse mapping via getnameinfo should give me localhost. And if I add something to the hosts file (assuming that it overrules the DNS), I want to get the name from there. And that should be independent of the name `localhost` or `localhorst`. – Andreas Mueller Jul 07 '17 at 06:44

0 Answers0