Proxy Connection Error 7
Contents |
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 more about Stack Overflow the http://stackoverflow.com/questions/9922562/how-to-resolve-curl-error-7-couldnt-connect-to-host company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to resolve cURL Error (7): couldn't connect to host? up vote 31 down vote favorite 12 I send an proxy server item code to a web service in xml format using cUrl(php). I get the correct response in localhost, but when do it server it shows cURL Error (7): couldn't connect to host And here's my code: function xml_post($post_xml, $url) { $user_agent = $_SERVER['HTTP_USER_AGENT']; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_xml); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); unable to connect // curl_setopt($ch, CURLOPT_PORT, $port); $data = curl_exec($ch); $curl_errno = curl_errno($ch); $curl_error = curl_error($ch); if ($curl_errno > 0) { echo "cURL Error ($curl_errno): $curl_error\n"; } else { echo "Data received\n"; } curl_close($ch); echo $data; } I send the item code to the tally and fetch the details from it. I tried using both the versions php 4+ and php5+, nothing works out Any solution. php xml curl share|improve this question edited Apr 8 at 15:48 chris85 15.2k51229 asked Mar 29 '12 at 9:26 Raj 160239 choose a proxy that uses a port 80 –user669677 Nov 13 '13 at 14:46 use curl verbose option to get more information –Preexo Jan 31 '14 at 17:39 I'll add two things here that eventually got my problem solved: 1. run cURL from the command line with --verbose 2. If you're on OSX with Little Snitch (or similar), look at that. –Stephen O'Flynn Jul 19 at 21:48 add a comment| 9 Answers 9 active oldest votes up vote 33 down vote CURL error code 7 (CURLE_COULDNT_CONNECT) is very explicit ... it means Failed to connect() to host or proxy. The following code would work on any system: $ch = curl_init("http://google.com"); // initialize curl handle curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); print($data); If you can not see google