title: AWS Gateway Timeout under threshold seconds
body: <p>I have a node (express) app running on AWS that is randomly returning 504 (GATEWAY_TIMEOUT) without reaching the actual timeout (60 sec) threshold:</p>
  
  <p><a href="https://i.stack.imgur.com/bxpV2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxpV2.png" alt="504 requests"></a></p>
  
  <p>You can see that the requests following the failed ones take more time than the "timed out" ones...</p>
  
  <p>On my express app I have:</p>
  
  <p><code>server.keepAliveTimeout = 65000;</code></p>
  
  <p>Any ideas?</p>
  
  <p>EDIT: Adding ELB Logs:</p>
  
  <p><code>2019-01-18T09:06:56.554353Z a38e67823174c11e9a984022fe7c311b 189.58.239.206:51399 - -1 -1 -1 504 0 0 0 "GET &lt;app_endpoint&gt; HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2</code></p>
  
  <p><code>2019-01-18T09:06:56.564478Z a38e67823174c11e9a984022fe7c311b 189.58.239.206:51400 - -1 -1 -1 504 0 0 0 "GET &lt;app_endpoint&gt; HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2</code></p>
  
  <p><code>2019-01-18T09:06:56.580591Z a38e67823174c11e9a984022fe7c311b 189.58.239.206:51401 - -1 -1 -1 504 0 0 0 "GET &lt;app_endpoint&gt; HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2</code></p>
  
  <p><code>2019-01-18T09:06:56.602049Z a38e67823174c11e9a984022fe7c311b 189.58.239.206:51398 - -1 -1 -1 504 0 0 0 "GET &lt;app_endpoint&gt; HTTP/1.1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2</code></p>