curl Failed to connect to domain.com port 9081: Connection refused

niman

Registered
Dec 3, 2019
1
0
0
Dhaka, Bangladesh
cPanel Access Level
Website Owner
In my localhost it work correctly but when it uploaded on my shared hosting it shows curl errors "Failed to connect to domain.com port 9081: Connection refused" .
Others curl request works fine on my shared host.
Anyone can give a solution?
My curl request is below
PHP:
$bkash_url = "https://www.domain.com:9081/dreamwave/merchant/trxcheck/sendmsg?user=<USENAME>&pass=<PASSWORD>&msisdn=<MERCHANT_NUMBER>&trxid=<TRANSACTION_ID>"";
$curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_PORT => 9081,
        CURLOPT_URL => $bkash_url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "GET",
        CURLOPT_HTTPHEADER => array(
            "cache-control: no-cache",
            "content-type: application/json"
        ),
    ));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,272
313
Houston
I removed the domain name from your post but before then I attempted to connect using curl over port 80 but I'm unable to even make a curl request to that server, I'd suggest discussing this issue with your hosting provider.

Code:
curl -vv domain.com
[LIST]
[*]Rebuilt URL to: domain.com/
[*]Trying <ipremoved>...
[*]TCP_NODELAY set
[*]Connection failed
[*]connect to <ipremoved> port 80 failed: Operation timed out
[*]Failed to connect to domain.com port 80: Operation timed out
[*]Closing connection 0
[/LIST]
curl: (7) Failed to connect to domain.com port 80: Operation timed out