Connection timed out while reading response header from upstream caused by session_start() hanging?
<p>I'm trying to troubleshoot the following: "Connection timed out while reading response header from upstream"</p>

<p>Setup is VestaCP latest version 0.9.8 running. PHP 5.5.9. apache and nginx as proxy.</p>

<p>I've spent hours trying different things. </p>

<p>I've looked here: <a href="https://stackoverflow.com/questions/18740635/nginx-upstream-timed-out-110-connection-timed-out-while-reading-response-hea">NGINX: upstream timed out (110: Connection timed out) while reading response header from upstream</a></p>

<p>and here: <a href="https://stackoverflow.com/questions/10395807/nginx-close-upstream-connection-after-request">nginx close upstream connection after request</a></p>

<p>Those answers suggest: setting <code>proxy_http_version 1.1;</code> and <code>proxy_set_header Connection "";</code></p>

<p>I did that but it didn't help. How can I troubleshoot this further and find the problem?</p>

<p>It seems erratic, if I restart nginx and apache2 (<code>service restart ...</code>) it will proccess one or two requests before throwing the 504 gateway timeout error and logging "<code>Connection timed out while reading response header from upstream</code>"</p>

<p>My main pages actually work fine (see: <a href="https://eastward.edu.au/" rel="nofollow noreferrer">https://eastward.edu.au/</a>). But any ajax requests sent to my backend (<a href="https://eastward.edu.au/~do" rel="nofollow noreferrer">https://eastward.edu.au/~do</a>) are coming back as timed out. </p>

<p>I drilled down a bit further and it seems that php <code>session_start();</code> could be where it is getting hung up? Whether it is that, or that is the catalyst I'm not sure.</p>

<p>That's as far as I've been able to figure out.</p>

<p><strong>EDIT</strong></p>

<p>Try doing one or two (fake) subscriptions on my homepage (<a href="https://eastward.edu.au/" rel="nofollow noreferrer">https://eastward.edu.au/</a>, top right), and then visit: <a href="https://eastward.edu.au/~do" rel="nofollow noreferrer">https://eastward.edu.au/~do</a></p>

<p>It should timeout after 90 seconds.</p>

<p>The actual error log reads:</p>

<p><code>2016/09/08 00:43:12 [error] 4706#4706: *152 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 1.144.96.101, server: eastward.edu.au, request: "POST /~do HTTP/1.1", upstream: "https://45.56.85.76:8443/~do", host: "eastward.edu.au", referrer: "https://eastward.edu.au/"</code></p>