Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURL - Error code: 6 Couldn't resolve host 'http://www.yahoo.com' - XAMPP

Tags:

php

curl

Does anyone know what happen on the error as below when calling curl even call yahoo page:

Error code 6 :Couldn't resolve host 'http://www.yahoo.com'; No data of requested type

PHP

 $sendurl = "http://www.yahoo.com";
 $ch = curl_init($sendurl);                                                                     
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);                                                                     
 $result = curl_exec($ch);

 if(!$result){
     echo $curl_errno($ch).":".curl_error($ch);
 }
like image 935
user831098 Avatar asked Mar 03 '26 09:03

user831098


2 Answers

This error mean that curl can't resolve host name.

There is problem with DNS server on computer where you run this script.

If you run script on your local computer then check it just open www.yahoo.com in your browser.

If you run script on remote server, then you should login to server by SHH and check ping www.yahoo.com. Or ask your hosting support team about this issue.

like image 109
newman Avatar answered Mar 05 '26 00:03

newman


I think you're missing options for allowing redirects and https. Check it in your browser -> you will get redirected to https URL.

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
like image 27
gskema Avatar answered Mar 05 '26 00:03

gskema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!