Curl Error On Url Couldn Connect To Host
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta curl couldn t connect to host Discuss the workings and policies of this site About Us Learn more curl 7 couldn t connect to host about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack curl (7) couldn't connect to host linux Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you,
Curl (7) Couldn't Connect To Host Localhost
helping each other. Join them; it only takes a minute: Sign up Curl not working, error: couldn't connect to host up vote 0 down vote favorite I am using curl to get weather information from a specific site api.wunderground.com and the issue is its not working. I have tried using the file_get_contents function also, but its not working curl error code 7 either. Here is my code for curl: function get_web_page($url) { //echo "curl:url
".$url."
"; $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 15, // timeout on connect CURLOPT_TIMEOUT => 15, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_PROXY => null, ); $ch = curl_init($url); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch,CURLINFO_EFFECTIVE_URL ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; //change errmsg here to errno if ($errmsg) { echo "CURL:".$errmsg."
"; } return $content; } $url = "http://api.wunderground.com/api/67927f145c532a19/geolookup/conditions/q/uae/dubai.json"; get_web_page($url); I have checked my server settings, curl is enabled and the server is using port 80. Can anybody help me with this I am out of ideas. php curl share|improve this question ed
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn curl (7) couldn't connect to host centos more about Stack Overflow the company Business Learn more about hiring developers or
Curl Couldn't Connect To Server
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow
Curl Failed To Connect Connection Refused
Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error: couldn't connect to host via CURL on same http://stackoverflow.com/questions/15217345/curl-not-working-error-couldnt-connect-to-host domain up vote 2 down vote favorite I have a URL - http://www.xxx.xxx.xxx/ 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 - error: couldn't connect to host Following is my code - function get_xml_via_curl($url) { $ch http://stackoverflow.com/questions/25420685/error-couldnt-connect-to-host-via-curl-on-same-domain = 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; } 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 - error: couldn't connect to host Updated Code - I modified the code on my server to - 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; } And the error from curl changes to following - error: Protocol http not supported or disabled in libcurl php apache curl share|improve this question edited Jan 29 '15 at 6:36 asked Aug 21 '14 at 7:34 Abijeet Patro 1,43912251 Possible helpful answer: stackoverflow.com/a/9923212/3000179 –ʰᵈˑ Aug 21 '14 at 7:40 It's working correctly for me. Weird. –Basit Saeed
Sample Code Accelerators Idea Lab Events Modern Service Experience Webinars User Groups Videos Support & Services Support Knowledge Base Manage My Service Requests Support Experience Ask Tech Support about Oracle http://communities.rightnow.com/posts/8f280425ad Service Cloud Ask Tech Support about Oracle Field Service Ask Tech Support about Co-Browse Ask Tech Support to turn on/off Oracle Service Cloud features Tune-Up’s Training Consulting Partners Support Notifications View Recent Org Service Requests View Utility Outages View Service Event Outages Developer Discussion ForumpublicCustomer PortalThis is a public ForumpublicRSSTopiccURL Error Code: 7 couldn't connect to hostAnsweredTopicposted June 11, connect to 2013 by Bill Kantz15495 Views, 5 CommentsTitle:cURL Error Code: 7 couldn't connect to hostContent:I am trying to connect to some sites using cURL the issue I get almost all sites return an error attempting to connect with the exception of google.com . The test code that I written trying to identify what the issue is listed below These are connect to host the results I get from the test: http://www.slashdot.org Result: Error Code: 7 couldn't connect to host HTTP Code: 0 http://www.fox.com Result: Error Code: 7 couldn't connect to host HTTP Code: 0 http://www.cnn.com Result: Error Code: 7 couldn't connect to host HTTP Code: 0 http://www.rightnow.com Result: Error Code: 7 couldn't connect to host HTTP Code: 0 http://www.sony.com Result: Error Code: 7 couldn't connect to host HTTP Code: 0 http://www.google.com Result: Operation completed without any errors HTTP Code: 200 http://www.vonage.com Result: Error Code: 7 couldn't connect to host HTTP Code: 0 http://www.stackoverflow.com Result: Error Code: 7 couldn't connect to host HTTP Code: 0 Is there some whitelist on RightNow's end? Can this be modified? Code Block: