首页 > PHP curl 无法解析域名

PHP curl 无法解析域名

LNMP,DNS设置无误,curl任意地址报错:

Couldn't resolve host 'example.com'

file_get_contents 报错:

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
  1. shell 中直接 curl -I http://example.com 正常,ping也正常
  2. curl设置 CURL_IPRESOLVE_V4 无效

好吧...找到问题了,PHP运行在chroot环境中,关掉就好了。


我有一个疑问,你的 example.com换成你具体需要的域名没有。有时候,运营商的DNS服务器可能没有对应的ip地址映射关系,从而找不到网站的。

【热门文章】
【热门文章】