Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Status Code for database is down

I have a page on my web site that reports on the health of the site and sets an HTTP 200 status code is everything is okay. This page is used by an external monitoring program to check that the site is up.

When this page is hit, I make a very lightweight DB proc call to see if the DB is up and okay. If this fails, I want to return a meaningful HTTP error code to the monitor to let it know that all is not well.

From what I can work out there's no HTTP status that says "a third party component that I rely on is down" so what what would you return in this case?

503 Service Unavailable...?

like image 514
Guy Avatar asked Sep 16 '09 17:09

Guy


People also ask

What is the status code if data not found?

404: “The requested resource was not found.” This is the most common error message of them all. This code means that the requested resource does not exist, and the server does not know if it ever existed.

What is HTTP status code1?

We tend to get -1 status codes when there are network issues or connection problems, so we display the user a network problems page in those cases.

What is the difference between 200 and 201 status code?

The 200 status code is by far the most common returned. It means, simply, that the request was received and understood and is being processed. A 201 status code indicates that a request was successful and as a result, a resource has been created (for example a new page).

What does the HTTP status code 204 represent in a REST service?

The HTTP 204 No Content success status response code indicates that a request has succeeded, but that the client doesn't need to navigate away from its current page.


2 Answers

That's exactly what a 503 is.

503 means that the server was relying on connecting some other service, which did not respond in time.

Server Error 5xx

Checked up on Wikipedia and the listing there seems to imply that a 504 would be the one I'm thinking of. Quite possibly the link over is outdated.

So:

504 Gateway Timeout

The server was acting as a gateway or proxy and did not receive a timely request from the downstream server.

like image 105
Tomas Avatar answered Sep 20 '22 17:09

Tomas


I would suspect that a 500 or 503 would be appropriate. 503 is generally used for overloaded or maintenance conditions, but I don't think it would be unreasonable to use it for your situation.

like image 24
Thomas Owens Avatar answered Sep 19 '22 17:09

Thomas Owens