I am connecting to a 3rd party API with php curl, on localhost it's working fine and is successfully connected. but with same code it returns failed: connection refused on live server.
$url = "http://suitefleetdms.com:8246/api/authenticateweb";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$verbose = fopen('php://temp', 'w+');
curl_setopt($curl, CURLOPT_STDERR, $verbose);
$headers = array(
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = '{"username":"cbs.dev@transcorp-intl.com","password":"MY_REAL_PASSWORD"}';
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo "Verbose information:\n<pre>", htmlspecialchars($verboseLog), "</pre>\n";
I tried connecting this domain:port from
- terminal with command
curl -v https://suitefleetdms.com:8246/api/authenticateweb
{expected response code 404 because missing body but concern here is establish connection} - postman (web based and app on MacOS), it connects successfully.
- MacOS Terminal , it connects successfully
- PHP cURL on localhost (xampp on macOS BigSur 11.1 PHP Version 7.4.1 ), it connects successfully
BUT whenever i run same PHP cURL code on live server it returns connection refused. PHP Version 7.4.21
attaching all screenshots
postman application
postman web
php curl on localhost
terminal macOS
Their API Documentation is here