I am running Apache locally on my MacBook Pro, which runs OS X Lion. Up until recently, the server has responded fine. Now, however, it seems to be slow to respond.

I made a request to visit a virtual host on my machine at 22:17:00. Apache did not start responding until 22:17:10. I checked my Apache logs and this is all there is: - - [28/Apr/2012:22:17:10 +0100] "GET / HTTP/1.1" 304 -

There doesn't seem to be anything holding it up that I can see from the access_log, and there are no errors in error_log.

This happens every few minutes, with intervals of normal speed responses in-between. Most notably when a connection has not been made in the last couple of minutes.

Does anyone have any ideas why this might be happening?

  • Apache running what? Static files? PHP? Ruby? Python? – devicenull Apr 28 '12 at 23:30

Using chrome developer tools (ctrl-shift-I) you can get an idea exactly at what stage the browser is hanging like so;

enter image description here

Also, you can start httpd under strace to watch exactly what it is waiting for (not sure what the equivalent OS X lion commands would be...)

# strace -t -T -f /usr/sbin/httpd -X -f /etc/httpd/conf/httpd.conf
23:19:35 execve("/usr/sbin/httpd", ["/usr/sbin/httpd", "-X", "-f", "/etc/httpd/conf/httpd.conf"], [/* 29 vars */]) = 0 <0.000008>

Obviously there will be quite a bit of output, but as your page is hanging for 10 seconds, you should have ample time to cut and paste the syscall that is taking 10 seconds.

You might want to check that HostnameLookups has been disabled in httpd.conf file;

When that is set to "on" httpd tried to do a DNS lookup for every incoming request, and this can be slow if your local naming is not working correctly, or are on an unreliable connection.

  • I just checked and it's already off, so unfortunately that isn't the problem. – Oliver Joseph Ash Apr 28 '12 at 21:33
  • it looks like dtrace is the mac OS equivalent of strace - troeger.eu/cms/?p=255 – Tom H Apr 28 '12 at 22:26
  • worked for me. I used the web dev tools in firefox though. same diff. I had forgotten about some dev stuff which I hadnt completed. it was taking 34 secs to load. – j0h May 27 '15 at 15:26

I found my problem here: https://stackoverflow.com/a/7553256/1082754

  • Glad you resolved the issue. Please be sure to mark your answer as "accepted" when you are able. – jscott Jul 20 '12 at 0:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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