关于curl时提示“ couldn't connect to host ”的异常信息

WBOY
Release: 2016-06-13 13:00:49
Original
1368 people have browsed it

关于curl时提示“ couldn't connect to host ”的错误信息
我使用curl函数去访问a.com网址,以前很正常,最近几天感觉非常不稳定,系统的错误日志里记录了不少curl访问出错的情况,一般都是提示:
couldn't connect to host

出现这样的情况,我以为是服务器找不到a.com这台主机了,但是登陆服务器ping a.com,却正常的获取到ip地址。这说明从服务器可以正确的解析a.com网址,排除服务器找不到目标主机的情况,那么剩下的可能是什么呢?


代码如下:

$url = 'http://a.com';<br />
<br />
$curl = curl_init($url);<br />
curl_setopt( $curl, CURLOPT_POST, 1 );<br />
curl_setopt( $curl, CURLOPT_POSTFIELDS, $Parameters );<br />
curl_setopt( $curl, CURLOPT_HEADER, 0 );<br />
curl_setopt( $curl, CURLOPT_RETURNTRANSFER , 1 );<br />
$response = curl_exec($curl);<br />
$curl_error = curl_error($curl);
Copy after login

------解决方案--------------------
直接访问那个地址能打开吗 
------解决方案--------------------
http://a.com  这么奇怪的域名 楼主确定可以打开吗?
------解决方案--------------------
那是访问不了那个域名啊,你换成baidu.com,我就不信还是couldn't connect to host这个
------解决方案--------------------
服务器的防火墙是否禁用了某些端口?

你说大部分时间是正常的。感觉跟服务器无关,可能网络繁忙,网速慢的原因呢

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!