Thursday, June 20, 2013

HTTP 503 Service unavailable error

Error

HTTP 503 STATUS or "Service unavailable" error returned after making an HTTP call

In my case i was calling a LONG RUNNING PHP script using AJAX


Solution


This error may be caused by any of the following

1- Server load is very high, server can't serve your request:
    ACTION: FREE SOME SERVER RESOURCES

2- The network call has been terminated before the server responds, may be because of a firewall or os/network timeout settings

3- The server has been restarted or the server process has been killed


My case was #2, i found that the ISP network settings terminates any TCP connection which spans more than 60 seconds (always terminating after 60 sec)

If this is your case, then you may need to change the design of your website to be asynchronous or to make your script returns any data before the timeout (HEARTBEAT)

You can make your request asynchronous by making an initial call to start the long running process and then do multiple calls on specific intervals to check if the long running process has finished and then return the response


Also check this relevant issue @ Amazon EC2




No comments:

Post a Comment