I have two servers s1 and s2. I have a file from s1 trying to access a file from s2 through php curl. The curl commands are written using php in s1/test.php and it is requesting s2/file.php.
I tested if curl is present in s1 and it is working fine with all urls except from s2. Also I can access s2 from localhost but not from s1. Please help me.
Here is my curl code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "here the url is placed");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if(!$data)
{
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo $data;
When i execute I am getting: "Curl error: couldn't connect to host"
couldn't connect to host
means that sonmething is wrong with the connection between the 2 servers. Check DNS's, ip's firewalls, opened ports and services...
What does running wget
in the CLI from s1 to s2 says?