HTTP status code when the server is down?

Solution 1:

It is usually the front end load balancer that sends the 503 Service Unavailable error if the actual web server is down. If you don't have a load balancer and the server behind it is down, or if the load balancer is down, the client will get a Connection timeout. If the server is up but Apache is not started the client will get Connection refused.

In the server down case the AJAX call itself will return an error.

response = url.open("http://...");
if (response == NULL) { /* handle Connection timeout / Conn refused */ }

In the 503 case your AJAX call actually performs a HTTP request, except that the error code says that there was a problem. Something like:

response = url.open("http://...");
if (response.code == 503) { /* handle service unavailable */ }

Hope that helps :)