title: Is it appropriate to return HTTP 504 Gateway Timeout as a response if a database server times out?
body: <p>In a REST service, is returning a 504 status code appropriate when the application times out waiting for a database query and is unable to complete the client's request? </p>
  
  <blockquote>
    <p><strong>504 Gateway Timeout</strong></p>
    
    <p>The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.</p>
  </blockquote>
  
  <hr>
  
  <p>Currently we're just showing a generic 500 error, which gets displayed in a UI as a generic server error. There is some utility in showing to the user that it is a database timeout error (perhaps along with suggestions to reduce the scope of what they're asking for), because at the least they're armed with more useful information if they contact whoever is responsible for their server.</p>
  
  <hr>
  
  <p>Any pointers to how other REST services handle a database timeout?</p>