title: nginx laravel keep getting 504 Gateway time out
body: <p>I keep getting 504 gateway time out error on nginx php7.0 ubuntu 16.04 for my laravel 5.3 website.</p>
  
  <p>My suspicion <code>whereHas</code> query is the problem. When I commented out the query, it seems working fine.
  the query</p>
  
  <pre><code>Item::with('image', 'brand', 'currency')-&gt;where('display', '&gt;=', 3)-&gt;whereHas('catitems', function($query){
                  $query-&gt;where('catitems.id', 5);
              })-&gt;inRandomOrder()-&gt;take(6)-&gt;get();
  </code></pre>
  
  <p>any idea whats wrong here?</p>
  
  <p>my vultr vps spec is 1GB RAM, 1 Core.</p>
  
  <p>This is the error log</p>
  
  <blockquote>
    <p>recv() failed (104: Connection reset by peer) while reading response
    header from upstream</p>
  </blockquote>
  
  <p>this is my buffer config </p>
  
  <pre><code>fastcgi_buffers 8 128k;
  fastcgi_buffer_size 128k;
  </code></pre>
  
  <p>Any idea how to solve this?</p>