超时从API获得 - PHP

I want to get data from an API using PHP,

First I use this php code to get it:

$uri = 'API-URL';
$response = file_get_contents($uri, false);
$results = json_decode($response);
var_dump($results->);

this code is work perfectly on Localhost and server and after a week the page still refreshed and after some minute I get this error

file_get_contents(API-URL): failed to open stream: Connection timed out

PS: this problem just on server, on localhost work perfectly

with some search on net I found CURL, I try to do it but the same problem,

page still refreshed and finally I get NULL

$uri = 'API-URL';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $uri);
$response = curl_exec($ch);
curl_close($ch);
$results = json_decode($response);
var_dump($results);

is there any solution to fix this problem ?