I am getting this error in my PHP Curl
* Hostname in DNS cache was stale, zapped
* Trying xxx.xx.x.xx...
* connect to xxx.xx.x.xx port 4005 failed: Connection refused
* Failed to connect to sample.website.net.au port 4005: Connection refused
* Closing connection 0
I have this code:
$ch = curl_init();
$headers = array(
'Content-type: text/xml',
'charset: utf-8',
'SOAPAction: urn:ServiceQualification#AddresSsearch',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); // This should always be set to 'TRUE' when in production to ensure the SSL is enabled.
$response = curl_exec ($ch);
if ($result === FALSE) {
printf("cUrl error (#%d): %s<br>\n", curl_errno($ch),
htmlspecialchars(curl_error($ch)));
}
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo "Verbose information:\n<pre>", htmlspecialchars($verboseLog), "</pre>\n";
curl_close ($ch);
return $response;
I don't know why I am having this error. I tried this one in my localhost, and it works perfectly, but when I uploaded it in my server, I am getting the said php curl error.
What seems to be the problem here? Do I need to contact the url that I am trying to connect?
I am banging my head now, your help will be greatly appreciated.
Thanks!
Connection refused:
Check if you may connect outgoing to port 4005. Possibly it's your firewall that blocks you.
Check if you may connect outgoing to port 4005. Possibly it's the remote firewall that blocks you.
Check if you can ping the remote host via your terminal:
ping 1.2.3.4 // this is the ip, you can also use the hostname.
Try connecting the remote host with specific port via your terminal:
telnet 1.2.3.4 4005
This is more easy than debugging via php code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With