title: error: couldn't connect to host via CURL on same domain
body: <p>I have a URL - <a href="http://www.xxx.xxx.xxx/" rel="nofollow">http://www.xxx.xxx.xxx/</a></p>
  
  <p>This URL, I'm able to open through the browser. I'm even able to call this URL via cURL from my machine, but when I'm calling it from the code on the same server and domain, it gives me an error - <code>error: couldn't connect to host</code></p>
  
  <p>Following is my code -</p>
  
  <pre><code>function get_xml_via_curl($url) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      echo $url;
      curl_setopt($ch, CURLOPT_FAILONERROR, 1);
      /*curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);*/
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 15);
      $returned = curl_exec($ch);
      if(curl_errno($ch)) {
          echo 'error: ' . curl_error($ch);
      }
      curl_close($ch);
      // $xml === False on failure
      $xml = simplexml_load_string($returned);
      return $xml;
  }
  </code></pre>
  
  <p>Like I said, on localhost this works. I can directly open the URL via the browser. But when I deploy the code on the same server and try calling via cURL, it gives me an error - <code>error: couldn't connect to host</code></p>
  
  <p>Updated Code -</p>
  
  <p>I modified the code on my server to - </p>
  
  <pre><code>function get_xml_via_curl($url) {
      $url = " http://www.xxx.xxx.xxx.xxx/";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_FAILONERROR, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 15);
      $returned = curl_exec($ch);
      if(curl_errno($ch)) {
          echo 'error: ' . curl_error($ch);
      }
      curl_close($ch);
      $xml = simplexml_load_string($returned);
      return $xml;
  }
  </code></pre>
  
  <p>And the error from curl changes to following -</p>
  
  <p><code>error: Protocol http not supported or disabled in libcurl</code></p>