HTTP Status Code for database is down

42,227

Solution 1

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.

Solution 2

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.

Share:
42,227

Related videos on Youtube

Guy
Author by

Guy

I am a consultant specializing in TypeScript/React/JavaScript/Node.js Full Stack. I also have a strong background in C#/.Net. I am available for hire.

Updated on April 28, 2020

Comments

  • Guy
    Guy almost 4 years

    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...?

  • Thomas Owens
    Thomas Owens over 14 years
    To me, it sounds like he wants to pass along a meaningful message to clients when the database is down. In that case, making a code isn't a good idea - how are clients supposed to interpret it? You should pick the right status code.
  • Jim
    Jim over 14 years
    i would have to agree that a 500 code would be most useful. there was an error server-side--your db is down. with that, you can still return any markup that you want.
  • Jonas Tomanga
    Jonas Tomanga over 6 years
    I am opting for 503 because it indicates that this is a temporary issue and the client can't try again after a particular time which can be specified in the header.
  • Prashanth
    Prashanth almost 6 years
    504 would be when the server was able to make a connection but didn't get a timely response. So, I feel that 503 is more suitable here because we are not even able to make a connection.