You should not look at it from your perspective (api providers), but rather from the point of view of consumers.
As an api consumer, I don't care when everything went wrong. I have one interface to work with, and this is your public api. How you chose the api implementation behind this interface does not matter to me.
So, for all that I know, you had an internal server error. You could not process my request, although it was completely legal. Therefore, you must return a status code of 500.
What you can (and really should always) do is return the error message to the body. If your api is json api then you should return a json formatted error message.
Do not think about looking good. Think about being explicit and predictable. The server encountered an unexpected state, which prevented it from completing the request.
Its 500.
Edit: you specify the database, and in the case of a database timeout, it is certainly 500.
/ JP
source share