ホームページ  >  記事  >  バックエンド開発  >  php出现curl couldn't connect to host怎么办

php出现curl couldn't connect to host怎么办

不言
不言オリジナル
2018-05-28 15:35:572641ブラウズ

php出现curl couldn't connect to host怎么办

php出现curl couldn't connect to host怎么办?

使用curl命令访问网站时报错:

[root@bqh-119 ~]# curl -I www.test.com
curl: (7) couldn't connect to host
[root@bqh-119 ~]# curl -V #查询版本以及支持的协议
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp 
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

首先看能ping通网站不,若ping不通,则去/etc/hotst下加解析地址:

60e7e7d96dc7be236accdf8848c8f6c.png

然后再查看防火墙是否开启或是否添加了访问规则:

6efa99b014b8c4c2dbbdb45259f9437.png

 

关闭防火墙后curl就正常了,很多情况下都是因防火墙规则拦截导致,当然也有其它配置原因导致。

更多相关知识,请访问PHP中文网

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。