Last Updated: February 25, 2016
·
5.787K
· wjonthomas

Speed up MAMP Pro/virtual host name resolution

Seems like it was taking Chrome (not sure about other browsers) way too long to resolve my local virtual hosts using MAMP Pro. After looking around at a lot of things people tried, this is the one I found to work for me. Hopefully it helps someone out here.

Also, if you use anything frontend tools that autorefresh your browser, but you've been noticing that sometimes when you save, it takes forever to refresh, this is why.

Open your /etc/hosts file and put all your virtual hosts on one line, separated by a space after your 127.0.0.1 entry above your virtual hosts. Here's a before/after screenshot of my hosts file to make it clear.

Tip: If you use Sublime Text 2, use multiple cursors to clear out all the unneccessary comments quickly and get everything on one line.

Before

Picture

After

Picture

Another popular tip I saw was to use anything but .local on OS X, since that may interfere with default settings Bonjour uses.

2 Responses
Add your response

Follow up on this technique... You will have to edit this file every time you edit your virtual hosts in MAMP. It doesn't overwrite the one-line entries, but it does re-add all the entries below it. All you have to do is copy your new entry and put it up with the others, and you can delete the entries MAMP added again. I still think it's worth it. If anyone knows of a way to change the output format that MAMP Pro outputs to the /etc/hosts file, that would surely be helpful, if it's even possible.

over 1 year ago ·

An alternative to messing with /etc/hosts (or your DNS) every time you make "local" changes in MAMP is to have Bonjour automatically multicast MAMP's .local domains on the network. No messing with /etc/hosts and domains can be accessed from any mac on the network... and no more slow .local DNS resolving. I'm not going back to /etc/hosts...

over 1 year ago ·