PHP Curl+connection refused

Viewed 13621

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!

1 Answers
Related