Categories
Uncategorized

Virtual hosts look up taking too long in OSX Lion

If your mac (OSX Lion) is taking too long to get pages with your local web server and you have virtual hosts setup, then it’s probably because it is checking the DNS servers before it checks for it in your /etc/hosts.

The way to resolve this is to have a ::1 entry in your hosts file for every 127.0.0.1 entry. Here’s an example:

127.0.0.1         example.com
::1               example.com

You will notice I have 2 entries for example.com. One is IPv4 and the other is IPv6. My requests to the local web server take almost no time at after I did that. I think Lion tries to use IPv6 before it uses IPv4 and since it doesn’t find any entries for that in your hosts file, it goes to the internet searching for that domain.

By Moazzam

Moazzam is a software developer working in the big apple. He has over a decade of experience in development. While most of his work involves developing web applications, he does development for Android and Windows Mobile in his spare time.

Leave a Reply

Your email address will not be published. Required fields are marked *