1

Curl seems to hang when making calls. This is breaking wordpress/wp-admin sites & the twillio helper library used for IP-SMS.

This issue appeared after installing vsftpd and creating new users.

script to test curl: (from google)

function nxs_cURLTest($url, $msg, $testText){  
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, $url); 
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  $response = curl_exec($ch); 
  $errmsg = curl_error($ch); 
  $cInfo = curl_getinfo($ch); 
  curl_close($ch); 
  echo "Testing ... ".$url." - ".$cInfo['url']."<br />";
  if (stripos($response, $testText)!==false) 
    echo "....".$msg." - OK<br />"; 
  else 
  { 
    echo "....<b style='color:red;'>".$msg." - Problem</b><br /><pre>"; 
    print_r($errmsg); 
    print_r($cInfo); 
    print_r(htmlentities($response)); 
    echo "</pre>There is a problem with cURL. You need to contact your server admin or hosting provider.";
  }
}

  nxs_cURLTest("http://www.nextscripts.com/", "HTTPS to NXS", "Social Networks");
  nxs_cURLTest("http://www.google.com/intl/en/contact/", "HTTP to Google", "Mountain View, CA");
  nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
  nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
  nxs_cURLTest("https://graph.facebook.com/", "HTTPS to API (Graph) Facebook", 'get');  
  nxs_cURLTest("https://www.linkedin.com/nhome/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/');

output:

Testing ... http://www.nextscripts.com/ - http://www.nextscripts.com/
....HTTPS to NXS - OK
Testing ... http://www.google.com/intl/en/contact/ - http://www.google.com/intl/en/contact/
....HTTP to Google - OK
Testing ... https://www.google.com/intl/en/contact/ - https://www.google.com/intl/en/contact/
....HTTPS to Google - Problem
Failed to connect to www.google.com port 443: Connection timed outArray
(
    [url] => https://www.google.com/intl/en/contact/
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 5.003154
    [namelookup_time] => 0.004183
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 
    [certinfo] => Array
        (
        )

    [primary_port] => 0
    [local_ip] => 
    [local_port] => 0
)
There is a problem with cURL. You need to contact your server admin or hosting provider.Testing ... https://www.facebook.com/ - https://www.facebook.com/
....HTTPS to Facebook - Problem
Failed to connect to www.facebook.com port 443: Connection timed outArray
(
    [url] => https://www.facebook.com/
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 5.003227
    [namelookup_time] => 0.004192
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 
    [certinfo] => Array
        (
        )

    [primary_port] => 0
    [local_ip] => 
    [local_port] => 0
)
There is a problem with cURL. You need to contact your server admin or hosting provider.Testing ... https://graph.facebook.com/ - https://graph.facebook.com/
....HTTPS to API (Graph) Facebook - Problem
Failed to connect to graph.facebook.com port 443: Connection timed outArray
(
    [url] => https://graph.facebook.com/
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 5.003548
    [namelookup_time] => 0.004187
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 
    [certinfo] => Array
        (
        )

    [primary_port] => 0
    [local_ip] => 
    [local_port] => 0
)
There is a problem with cURL. You need to contact your server admin or hosting provider.Testing ... https://www.linkedin.com/nhome/ - https://www.linkedin.com/nhome/
....HTTPS to LinkedIn - Problem
Failed to connect to www.linkedin.com port 443: Connection timed outArray
(
    [url] => https://www.linkedin.com/nhome/
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 5.003194
    [namelookup_time] => 0.004179
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 
    [certinfo] => Array
        (
        )

    [primary_port] => 0
    [local_ip] => 
    [local_port] => 0
)
There is a problem with cURL. You need to contact your server admin or hosting provider.

Curl is still installed on my server, i have verified this through phpinfo();

reinstalling the curl module did not help.

sudo apt-get install php5-curl
sudo service apache2 restart
7
  • 1
    Failed to connect to X port 443: Connection timed out
    – alexus
    Apr 21, 2016 at 14:00
  • yes, the connection is apparently trying to go over a secure port. Meaning this is an issue with my SSL certificate? Apr 21, 2016 at 14:01
  • 1
    check network, firewall, etc... in shell try curl -I www.google.com
    – alexus
    Apr 21, 2016 at 14:02
  • I've opened port 443 to all outgoing on my AWS-EC2 instance. that command outputted Failed to connect to www.google.com port 80: connection timed out. @alexus Apr 21, 2016 at 14:06
  • Security Group should not be blocking anything out, if you're running firewall on your Linux, disable it temporary just to pinpoint where actual issue is.
    – alexus
    Apr 21, 2016 at 14:08

1 Answer 1

3
Failed to connect to X port 443: Connection timed out

this looks like more of a networking issue, rather then php and/or curl, one should try to replicate it via shell's curl and/or wget.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .