Reputation:
I found articles with the same issue but the answers didn't fix my problem, so I m trying to curl from and to the same Ubuntu server, but it returns: Error in cURL: Could not resolve host: www.domain.com
when i do: wget www.domain.com
, i have : |127.0.0.1|:443... failed: Connection refused.
when I do: telnet www.domain.com
, I have: Unable to connect to remote host: Connection refused
I added to /etc/hosts the line: 127.0.0.1 domain.com
I have listed netstat on 443 : netstat -tlpen | grep 443
but no 0.0.0.0:443 or 127.0.0.1:443 is in the list
When I curl the same domain from another server, it returns the wanted result. Here is my Php curl code :
<?php
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL, 'https://www.fakedomain.co');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($curl);
if($data === false) {
echo "Error in cURL : " . curl_error($curl);
}
else{
echo $data;
}
Upvotes: 1
Views: 5097
Reputation:
I finally fixed my problem, Updated the /etc/hosts file like this :
127.0.0.1 localhost
127.0.1.1 domain.com
Server IP domain.com
Upvotes: 1