title: PHP Curl Cannot Connect to Host on Own Server
body: <p>I have a PHP script that uses cURL to access a file also located on my server (installed email marketing program). I wrote a quick script to test my cURL installation and it fails when pointed at a file on my own server. The script is:</p>
  
  <pre><code>$ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "http://www.mysite.com/test.php");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  $contents = curl_exec($ch);
  
  if($contents) {
      echo $contents;
  } else {
      $err = curl_error($ch);
      echo $err;
  }
  
  curl_close($ch);
  </code></pre>
  
  <p>When I run this code, it returns an error: <em>couldn't connect to host</em></p>
  
  <p>If I change the URL to <em>http://www.google.com</em> or any other site, it works just fine. Also, when I try to open the specific page via cURL on another server, it works like it should. The assumptions I'm making from these tests is that the PHP cURL is installed and (kinda) working and that the problem is not in the page that is trying to be opened.</p>
  
  <p>I thought it might be a port issue, so I tried specifying the port with the same result (not connecting to host). I tried both <code>curl_setopt</code> and <code>http://www.mysite.com:80/</code> to specify a port I know to be open.</p>
  
  <p>This leads me to believe that the issue is something in my apache installation, but I'm not an apache expert and I've been banging my head against Google all day to no avail. Any ideas what could cause such a specific cURL failure?</p>