file_get_contents():php_network_getaddresses:getaddrinfo失败 [英] file_get_contents(): php_network_getaddresses: getaddrinfo failed

查看:695
本文介绍了file_get_contents():php_network_getaddresses:getaddrinfo失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用cron作业将一些服务器的某些值更新为另一个服务器。我使用file_get_contents()。

I'm trying to update some values from one server to another server with a cron job. I use file_get_contents().

奇怪的是,这偶尔会失败。一分钟的工作,另一分钟,它将无法工作。
我收到这两个错误:

The strange thing is that this fails occasionally. One minute it works, another minute it won't work. I receive these two errors:


PHP警告:file_get_contents():php_network_getaddresses:getaddrinfo失败:名称或服务不知道

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

PHP警告:file_get_contents():无法打开流:php_network_getaddresses:getaddrinfo failed:名称或服务未知

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

和:


PHP警告:file_get_contents():php_network_getaddresses:getaddrinfo失败:没有与主机名关联的地址

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

PHP警告:file_get_contents():无法打开流:php_network_getaddresses:getaddrinfo失败:没有与主机名关联的地址

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

我已登录到遇到此问题的服务器。使用ping或traceroute工作正常,所以我排除了DNS问题。我也添加了谷歌DNS名称服务器,以确保。使用完全相同的代码的第三个服务器没有这个问题,所以它看起来是一个问题在调用结束,而不是响应结束。

I've logged into the server that experiences this problem. Using ping or traceroute works fine, so I've ruled out DNS issues. I've also added the google DNS nameservers just to be sure. A third server that uses the exact same code doesn't have this problem, so it looks to be a problem on the "calling" end, not the "responding" end. Replacing the hostname with IP is not an option for this case.

有没有人知道如何解决这个问题?

Does anyone know how to solve this?

推荐答案

在我的情况下,麻烦的是Apache在启动时从 /etc/resolv.conf 中获取DNS条目。当我启动我的Apache时,网络尚未设置。重新启动Apache(配置网络后)解决了我的问题。

In my case, the trouble was that Apache get the DNS entries from /etc/resolv.conf when it starts. By the time I started my Apache, the network was not set yet. Restarting Apache (after networking is configured) solved the problem for me.

我在我的博客文章 http://diogomelo.net/blog/16/Warning-file_get_contents-php_network_getaddresses -getaddrinfo-failed-No-address-associated-with-hostname

这篇关于file_get_contents():php_network_getaddresses:getaddrinfo失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆