Php – What Happens When Apache Times Out

apache-2.2curlloggingPHPtimeout

I am a PHP developer and I just spent a good amount of time trying to track down a very strange problem the users of our web application were reporting. It turns out due to a slow API call over the internet (using cURL via PHP) Apache was timing out. I checked httpd.conf and the TimeOut directive was set to 12. I bumped it up to 120 for testing purposes and the problem went away!

When the time out would happen the user's browser would display an error similar to "The server dropped the connection." The error message changed depending on what browser was used and cURL would just say that the response from the server was empty. This behavior seems to make sense but I am bothered that Apache didn't log these timeouts or report any errors. Instead it just shutdown leaving us puzzled as to what was happening until we guessed it was a timeout.

Is there an option to log timeouts or some way we can monitor for this?

Best Answer

It was probably returning a 504 status code, which the browser interpreted as the above error message. Check your logs for that response code.