gpt4 book ai didi

php - 文件获取内容(): php_network_getaddresses: getaddrinfo failed

转载 作者:可可西里 更新时间:2023-10-31 22:12:20 27 4
gpt4 key购买 nike

我正在尝试使用 cron 作业将一些值从一台服务器更新到另一台服务器。我使用 file_get_contents()。

奇怪的是,这偶尔会失败。一分钟它起作用,一分钟它就不起作用。我收到这两个错误:

PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known

PHP Warning: file_get_contents(): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known

和:

PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname

PHP Warning: file_get_contents(): failed to open stream: php_network_getaddresses: getaddrinfo failed: No address associated with hostname

我已经登录到遇到此问题的服务器。使用 ping 或 traceroute 工作正常,所以我已经排除了 DNS 问题。为了确定,我还添加了 google DNS 名称服务器。使用完全相同代码的第三台服务器没有这个问题,所以它看起来是“调用”端的问题,而不是“响应”端的问题。用 IP 替换主机名不是这种情况的选项。

有人知道怎么解决吗?

最佳答案

在我的例子中,问题在于 Apache 在启动时从 /etc/resolv.conf 获取 DNS 条目。当我启动我的 Apache 时,网络还没有设置好。重新启动 Apache(在配置网络后)解决了我的问题。

我在我的博文 http://diogomelo.net/blog/16/Warning-file_get_contents-php_network_getaddresses-getaddrinfo-failed-No-address-associated-with-hostname 上更详细地解释了这个案例

关于php - 文件获取内容(): php_network_getaddresses: getaddrinfo failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23386364/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com