title: cURL request via PHP causes local nginx server to timeout
body: <p>I've attempting to fetch some <strong>json</strong> via <strong>cURL</strong> in <strong>PHP</strong>:</p>
  <pre><code>$params = array(
      'need' =&gt; 'verify',
      'access_token' =&gt; '123456789'
  );
  $paramsString = http_build_query($params);
  
  $json_url = &quot;http://localhost:8888/api/access-token-dummy.php&quot;; 
   
  $crl = curl_init();
  curl_setopt($crl, CURLOPT_URL, $json_url);
  curl_setopt($crl,CURLOPT_POST, count($params));
  curl_setopt($crl,CURLOPT_POSTFIELDS, $paramsString);
  $json = curl_exec($crl);
  curl_close($crl);
  
  $accessArray = json_decode($json, TRUE);
  </code></pre>
  <p>I was getting <code>504 Gateway Time-Out</code> from the url, which is local and didn't make sense to me. It definitely existed and was accessible from browsers. However, I noticed that once I attempted to request it via the above method as a <strong>cURL</strong> request in <strong>PHP 7</strong>, all other methods caused timeouts too (e.g. a refresh in a browser url that previously worked now returns a timeout) from after the point I tried this cURL request but not before (when the url would be fetched almost instantly, as expected).</p>
  <p>It's an nginx 1.13.2 server and is hosting both the php making this request and the php url that the json is requested from. On top of this, I have a react server on a different port for the frontend. I mention this as I may have seen a reference before to this causing a conflict of sorts?</p>
  <p>The CPU of the server never spikes and the url becomes accessible to browsers after a minute or two of waiting. It's never accessible via the cURL command, it always creates a timeout and prevents other requests for the next minute or two.</p>
  <p>The URL contents being requested doesn't appear to matter. I've recreated it as minimally as the following and it still cause the same issue:</p>
  <pre><code>&lt;?PHP
  
  header('Content-type: application/json;charset=utf-8');
  
  $returnArray = [];
  $returnArray['message_user'] = &quot;success&quot;;
  $returnJSON = json_encode($returnArray);
  echo $returnJSON;
  
  ?&gt;
  </code></pre>
  <p>Nginx logs don't say too much but the following appears after the problem:</p>
  
  <pre><code>2020/10/22 17:00:23 [error] 52847#0: *49 upstream timed out (60: Operation timed out) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: &quot;POST /api/db-fetchurl.php HTTP/1.1&quot;, upstream: &quot;nginxFastCGI.sock&quot;, host: &quot;localhost:8888&quot;, referrer: &quot;http://localhost:3000/requesturl&quot;
  </code></pre>