How can I eliminate slow resolving/loading of localhost/virtualhost (a 2-3 second lag) on Mac OS X Lion?

前端 未结 13 891
梦毁少年i
梦毁少年i 2020-12-04 06:00

Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow

13条回答
  •  感动是毒
    2020-12-04 06:23

    I had the same problem, also on Lion.

    Strangely, my solution was the opposite of Jeremy's. I had a whole bunch of someproject.dev entries on one line in /etc/hosts. Loading a site on any of them the first time took forever, like a minute or so. If I used it again within 5 seconds or so it was very fast, but much longer and it would again take a minute. I had suspected all sorts of things, mysql connections, Ruby versions, Rails bugs, Apache, Phusion Passenger. Until I finally looked at the Console and realized that DNS lookups were being attempted.

    So, I put all of them on seperate lines:

    127.0.0.1 localhost
    
    127.0.0.1 myproject.dev
    
    127.0.0.1 myotherproject.dev
    

    And suddenly everything was snappy again. Same on both my machines.

提交回复
热议问题