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

I'm running:

MAMP Pro v 2.0.5 OSX Lion v 10.7.4 Chrome v 21.0.1180.82 FireFox v 14.0.1

I am NOT using .local addresses for my sites. It takes almost a minute for pages to load! Basically unusable. I followed a suggestion I found on Stack Overflow to edit the etc/hosts and convert...

127.0.0.1 example1.dev
127.0.0.1 example2.dev
127.0.0.1 example3.dev

to...

127.0.0.1 example1.dev example2.dev example3.dev

This worked initially. But then within a few weeks I was crawling again. I just edited /etc/hosts again and the pages load quickly again. That's nice, but I still have no idea what's going on and I have no reason to believe it won't slow down again.

Why does editing /etc/hosts make a difference? What's going on here?

UPDATE: I think I figured out why the problem keeps coming back. Whenever I edit /etc/hosts manually, I have to login as an admin (sudo?) to make changes. For the next couple minutes my pages are super quick. Then I guess my sudo credentials expire and I go back to loading pages at a snails pace.

By the way, why the down votes? At least comment and tell me why.

share|improve this question
add comment

1 Answer

When you first send query in your browser it will look for the entry in your /etc/hosts If you have your names configured it wont bother external DNS to resolve name. However if the name cannot be found it will delay with the response as the name cannot be resolved. Its the way system BSD system works not MAMP. The question is why you have to keep editing your /etc/hosts? Its common to make changes there if you work on different project so that you dont have to change the code.

share|improve this answer
    
I think I figured out why the problem keeps coming back. I think MAMP changes the etc/hosts file BACK to single lines (first code block above). Whenever I edit the file manually, I change to single line and it fixes the problem. –  SDP Aug 29 '12 at 16:25
    
Correction! After further testing the actual syntax of the host files doesn't seem to matter. It's the fact that I have to login as an admin (sudo?) to make changes. For the next couple minutes my pages are super quick. Then I guess my sudo credentials expire and I go back to loading pages at a snails pace. –  SDP Aug 29 '12 at 18:09
    
You can try to write protect /etc/hosts file sudo chmod -w /etc/hosts Also change ownership to root chown root /etc/hosts . That would be some kind of work around that could work in your case. –  BlueNile Aug 30 '12 at 23:27
    
That sounds interesting. Is that risky at all? I'm not great with the command line. Can you tell me the exact snippet? –  SDP Aug 31 '12 at 1:11
    
In essence /etc/hosts should belong to root and root should be able to read and write to it. You can check the file permissions: ls -l /etc/hosts The output should look something like that: -rw-r--r-- 1 root wheel 865 Aug 30 11:51 /etc/hosts First rw means that owner (root) is able to read and write to it and the rest group and others can r - read only. This is important beause you're saying that this file is being hanged by MAMP. MAMP cant change it without root permissions. Check how your ls output looks like and compare. You cant break it by changing it to read only. Its your system! –  BlueNile Aug 31 '12 at 4:53
show 4 more comments

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.