Php – file_get_contents failed to open stream: Connection refused godaddy server with remote connection server

phpphpinforemote-serversql-server

Our url is remote url.i can run through Ip address.it thrown error as "file_get_contents failed to open stream: Connection refused".I have use this code.

code:

$html = file_get_contents('http://xx.xxx.xx.xx:xxxx/apps/index.php');
print_r($html);
var_dump($html); 

What does this error?

Best Solution

A lot of hosts will prevent you from loading files from remote URLs for security reasons (allow_url_fopen setting in php.ini). It's better to use CURL to download the contents of the file.

<?php
$url = 'http://xx.xxx.xx.xx:xxxx/apps/index.php';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

Ref: Get file content via PHP cURL

HTH :)