MAMP Pro slow name resolving with .local vhosts in Lion (fix)

An issue I’ve encountered with MAMP Pro since having upgraded to OS X Lion was that requests to vhosts served via MAMP took their time to load: after about 3 to 5 seconds of loading, the site would finally load.

The most tricky part in this issue is that it only happens if you have a domain ending in .local, such as mysite.local. If you’d rename the site to, it’d be — … beware, buzzword coming up … — snappy again.

Turns out, after a few Google Search Coupons, that the culprit is Bonjour (emphasis mine):

The Multicast DNS feature of Bonjour technology allows devices on a local network to connect to each other by name without a separate DNS server. By default, any hostname ending in .local is treated as a Bonjour host rather than by querying the DNS server entries in Network preferences.

Though the .local domain is not defined as a valid top-level domain on the Internet, some private networks have DNS servers that assign hostnames in the .local domain. By default Mac OS X does not use the DNS server to resolve these names. This may result in unexpected failures to connect to .local hostnames defined by your server.

To fix this problem (without having to rename each vhost) you need to add IPv6 entries for each of your vhosts in your /etc/hosts file:

::1 mysite.local
fe80::1%lo0 mysite.local mysite.local

After that, .local vhosts load fast again. I’ve created an issue on the MAMP bug tracker for this, requesting the author to automatically add IPv6 entries to the hosts file when creating/editing a vhost. Hope to see this fixed in a future version. For now, the fix above will have to do.

Note that after restarting MAMP, the IPv6 entries will be gone … yeah, so that bug needs to fixed soon (either by Apple, or by MAMP). If you don’t want all the hassle after a restart, you might consider renaming your vhosts to .dev (anything but .local will do) UPDATE 2011.12.18: If you tab-delimit the vhosts (a rather unknown trick) for the ::1 entry, MAMP won’t delete it when reloading MAMP/adding a new vhost. Eventually, your hosts file will look like something this:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##	localhost	broadcasthost
::1	localhost	mysite.local	myothersite.local	anothersite.local	yetanothersite.local
fe80::1%lo0	localhost mysite.local myothersite.local anothersite.local yetanothersite.local
Did this help you out? Like what you see?
Consider donating.

I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!

☕️ Buy me a Coffee ($3)

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Join the Conversation


  1. Oh, thank heavens!! This has been bothering me for a while. Finally a straight answer. Thank you!

  2. Thank you! After all the “just dont use .local”-fixes finally one that works without changing all the dev-tlds!

  3. Wohoo! Thanks!
    Mind the space after ::1 and localhost and then tabs to your local sites.

  4. I’m a new Mac user and couldn’t figure this out for love nor money as I never had any problems on windows and WAMP.
    I, my Mac and iPad thank you V much.

  5. Using .dev has the same issue. Adding the IPV6 vhost entries resolves this. Becoming an epic pain if you’re serving many vhosts with MAMP Pro.

    MAMP 2.0.5 on Lion.

  6. Had the same problem with .local addresses on Mountain Lion.

    This fixed it, Thank You!

  7. I’m developing a facebook application and I was going crazy with this lion fail.

    I was searching how to activate in mysql the slow queries to trace the problem and suddenly your answer appears :))

    Thank you for avoid me a big headache.

  8. This is a FANTASTIC find! I cannot tell you how many weeks I was racking my brains on this one. And to top it off, I have a Windows 7 laptop along with my dev desktop and I do NOT have this issue on there….the reason…I do NOT have any apple software installed on the laptop! This post just answered the “why does my laptop not have this issue?” question for me.

    I have a small article written up on my site as well, but I am going to update it with a link back to this little gem 😉

    Thanks for solving this dilemma!

  9. Follow up comment on this.

    I did some more experimenting on this and discovered that even if I do not update the hosts file with the ipV6 data, I can have my site.local on any line that starts like

    As long as it is not the FIRST entry in the file (windows) it works: site site.local

    If I move site.local to be first before anything else on that line, it will break. Normally I would create my hosts as: site.local site (This will break)
    So now I do: site site.local (This works after I restart Apache)

    Not sure how that fares with the bug you mention in your post, but thought I would pass this along too….I will update my post on my site as well.

    1. Chris, thanks for your reply. Wasn’t aware it also affected Windows computers, yet now that you’ve mentioned it it’s rather logical indeed (as it’s Bonjour, which also exists on Windows). You’ve found a rather strange fix, but that doesn’t surprise me as it’s a strange bug to begin with 🙂

  10. Why doesn’t it work for me (using Mountain Lion)? In MAMP Pro 2.1.2 i’ve created my new host called “devhost” then added the following on top of the hosts file: devhost localhost
    ::1 devhost localhost
    fe80::1%lo0 devhost localhost

    When I restart MAMP, it kicks out those lines and again adds its own which are: localhost
    ::1 localhost broadcasthost
    Not only that it kicks out my lines – it bothers me it even doesn’t mention “devhost” anywhere throughout. What have I missed? I delimited with tabs all the way, as described…

  11. So here is the problem: it didn’t work for me because i was using php 5.5.3 in mamp. so here is what you do if your using that one.

    it explains it here:

    your php.ini file should look like this:
    ; opcache.memory_consumption=128
    ; opcache.interned_strings_buffer=8
    ; opcache.max_accelerated_files=4000
    ; opcache.revalidate_freq=60
    ; opcache.fast_shutdown=1
    ; opcache.enable_cli=1

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.