Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running MAMP on OS X 10.7. I've set up a virtual host in Apache, like so:

<Directory "/sites/example.com/">
Allow From All
AllowOverride All
</Directory>
<VirtualHost *:80>
    ServerName "example.local"
    ServerAlias "www.example.local"
    DocumentRoot "/sites/example.com"
</VirtualHost>

In /etc/hosts I've added this:

127.0.0.1 example.local

Everything works fine, and up to maybe a week or two ago was very fast. I'm not sure what changed, but now the DNS Lookup portion of the request takes upwards of 5 seconds nearly every time the page is loaded, as reported by both Firebug and Chrome.

Pinging the local address looks good:

->ping example.local
PING example.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.073 ms

Here's what Chrome shows:

Chrome Network Panel Output

If I refresh immediately after the first connection, the DNS lookup appears to be cached. But refreshing again a short time later causes the slow lookup again.

Any help would be appreciated!

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Well, example.local is typically an mDNS (Zeroconf) address, so there's every possibility that your mDNS config has broken in some way, and it's taking a few seconds for that to timeout before it falls back to /etc/hosts.

Why not just add localhost as a ServerAlias and just access it via that name? Otherwise, at least use a domain that doesn't have a top-level domain that has a different meaning to your system.

share|improve this answer
2  
Thanks, changing to example.dev seems to have solved this issue. Any hints on how I can see where mDNS may be having an issue? As I said, this worked fine for a long while and only recently started acting up. –  Ian Jul 23 '11 at 17:13
    
@Ian and rest of world: I am facing the same problem. any hints on solving it and still using anything.local as an domain? –  scube Nov 25 '11 at 15:20
1  
@scube: You've got two choices: tell your system not to interpret .local as being an mDNS domain, or use something that your system doesn't interpret as an mDNS domain. –  womble Nov 26 '11 at 2:22
    
Thanks a million. –  Prasad Rajapaksha Jul 19 '13 at 5:42

Yuo can also use domains which don't have .something, so just example without the .local. As mentioned here http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/ it appears OSX uses the .local for Bonjour.

I tested using just example without the .local and it appears to be solving this issue.

share|improve this answer

I've had this issue with non .local sites when using AJAX- I managed to fix it by adding the following lines to /etc/hosts

::1 slow-site.url      
fe80::1%lo0 slow-site.url

above the main block of sites for each offending site where 'slow-site.url' is 'example.local' or whatever.

it's a IPv6 address - more details here:

http://superuser.com/questions/241642/what-is-the-relevance-of-fe801lo0-localhost-in-etc-hosts

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.