I just ran into a problem that I could not connect to MySQL on localhost. WHen changing localhost to 127.0.0.1, things worked. Than I fount that the etc\hosts file had the entry for localhost commented out.
The comment in the hosts file read: "name resolution is handled within dns itself"
Interestingly enough, a number of programs did not find this issue.
But now my question is where/how do I check that this entry is correct in the DNS service and does anyone have any idea what I need to do (other than editing localhost in the hosts file) to make this work as was intended?
Editing the HOSTs file should be all that is needed to update ip to name resolution locally for a client system. If you need to flush out the local resolver cache, refer to ipconfig commands.
In an environment where it's just the localhost client, the local DNS Client service handles the initial resolution
- Proposed as answer by cschaar Tuesday, September 21, 2010 8:51 PM
You should give others a chance before you give up.
I have not personally come accross the issue you described where the hosts file had the localhosts entry commented out, but the way that I have resolved to ensure that "localhosts" is resolved correctly in all cases, is by creating a host (A) record entry in your foward lookup zones called "localhost" and point it to 127.0.0.1.
This will ensure that if anyone has purposely removed the localhost entry from the hosts file or if it has been commented for some reason, your DNS client will perform a lookup in the primary zone for a record called "localhost". Of course, the OS will append the domain suffix, but it wont matter since it will find it in DNS and return the correct IP. If you have more than one zone, I would create this record in each zone to ensure that all hosts are covered, no matter what domain suffix they are configured to use for DNS.
I hope that this at least partially answered your question on what can be done to mitigate this issue without having to modify the local hosts file as you requested.
Visit: anITKB.com, an IT Knowledge Base.