title: PHP cURL request to same server returning false
body: <p>I've searched high and low for the answer to this question but cant find anything...</p>
  
  <p>We've got a single server and on it we've got a PHP service with an API.</p>
  
  <p>We've recently written an PHP app which interacts with the API. When it goes live the API and the app will be on the same server.</p>
  
  <p>However, when they are on the same server the cURL requests from the app to the API always return false. I'm sure this must be something to do with the way that the request is being routed by the server. Is there any way to make this work properly?</p>
  
  <pre><code>$url = 'http://api.some_address_on_the_same_server.com';
  $postdata = array(...);
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  $result = curl_exec($ch); // $result is always false when on the same server for some reason
  curl_close($ch);
  </code></pre>