I just came across a server that does not respond to things like ping localhost
or mysql -h localhost
- I believe this is because localhost is not defined in the hosts file.
On just about every machine I've used localhost
has been an entry in the hosts file. Is there any good reasons not to define it - like possible security concerns? Or is this something that probably should be configured by default and perhaps is just missing?
Yes it's good. As you've already found out, there are certain programs (like mysql) that expect to be able to connect to localhost. Without that entry in your hosts file, programs cannot resolve that name to the proper IP address (in this case, the loopback address of 127.0.0.1).
There may be different ways of resolving localhost sometimes, but really, why would you not want to put it in there? There is no good reason not to.
I believe it absolutely should be defined in the
hosts
file.