简体   繁体   English

cUrl 给出常数 http 代码 0 => 错误 6 的问题

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

Hello and foremost thank you for your minute!您好,首先感谢您的宝贵时间!

I am having troubles with cURL.我在使用 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..."错误代码的每个响应都是“无法解析主机:....url 正在搜索...”

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. -> Google 被放置为测试参考。 But all return alike.但所有的回报都是一样的。 This same issue occurs regardless if I set peer to false.无论我是否将 peer 设置为 false,都会出现同样的问题。

Solved解决了

In my case, I had the server configurations files misconfigured.就我而言,我的服务器配置文件配置错误。

I went to./etc/resolv.cnf.我去了./etc/resolv.cnf。 Here I added the nameservers properly.在这里,我正确添加了名称服务器。

Hope it helps someone else coming across this issue!希望它可以帮助其他人遇到这个问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM