Skip to content
Advertisement

Problems with cUrl giving constant http code 0 => error 6

Hello and foremost thank you for your minute!

I am having troubles with cURL. This seems to work perfect on my localhost but on my server it just doesn’t send off requests. Each response of the error code is “Could not resolve host: ….the url im searching…”

I haven’t found much documentation on similiar errors online and it seems not much have encountered this issue.

$ch = curl_init() or die("Error");
curl_setopt($ch, CURLOPT_URL, "www.google.com");    
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec( $ch );
if(!curl_exec( $ch ))
{
    echo 'error:' . curl_error($ch);
var_dump(curl_getinfo($ch));
}
curl_close( $ch );

-> Google was placed as a test reference. But all return alike. This same issue occurs regardless if I set peer to false.

Advertisement

Answer

Solved

In my case, I had the server configurations files misconfigured.

I went to ./etc/resolv.cnf. Here I added the nameservers properly.

Hope it helps someone else coming across this issue!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement