file() [function.file]: php_network_getaddresses: getaddrinfo failed: 名称解析暂时失败

发布于 2024-09-02 12:59:33 字数 293 浏览 2 评论 0原文

当我从文件获取内容时出现以下错误(“http://www.otherdomain.com”) 。

file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

域服务器是linux。

如何解决这个问题?

I got the following error when I get contents from file("http://www.otherdomain.com").

file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution

The domain server is linux.

How to resolve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

蘸点软妹酱 2024-09-09 12:59:33

引用:

如果您在使用 fopen("url...") 时遇到问题,但您可以运行 'host
url' 在 shell 窗口中并获取
正确的查找,这就是原因...

这让我头疼不已
一整天都在反对——终于我发现了
隐藏在错误报告中的答案,
但我认为它确实应该更多
突出!

当您使用
带 DHCP 的 ADSL 线路(就像我们的
办公室)...当 ADSL 调制解调器更新时
DHCP租约,也可以切换
DNS 服务器,这让 apache 感到困惑
(以及 PHP) - 意味着你
无法从 PHP 中查找主机,
即使您可以
命令行......短期
解决方案是重新启动apache。

你会得到“php_network_getaddresses:
getaddrinfo 失败:暂时失败
在名称解析中...”消息为
症状。重启apache,就可以了
走了:-)

西蒙

Simon 在 php.net 的评论

Quoting:

If you're having problems with fopen("url...") but you can run 'host
url' in a shell window and get the
correct lookup, here's why...

This has had me banging my head
against it all day - finally I found
the answer buried in the bug reports,
but figured it should really be more
prominent!

The problem happens when you're on an
ADSL line with DHCP (like our
office)... When the ADSL modem renews
the DHCP lease, you can also switch
DNS servers, which confuses apache
(and hence PHP) - meaning that you
can't look up hosts from within PHP,
even though you can from the
commandline.... The short-term
solution is to restart apache.

You'll get "php_network_getaddresses:
getaddrinfo failed: Temporary failure
in name resolution in ..." messages as
symptoms. Restart apache, and they're
gone :-)

Simon

Comment by Simon at php.net

鱼窥荷 2024-09-09 12:59:33

确保可以从您的服务器访问该网站。
还要确保您使用的 DNS 服务器设置正确。

如果您确定该网站正在运行...尝试修改 /etc/hosts 文件并添加网站的 IP 以进行测试,然后尝试找出它无法解析域名的原因。

make sure that website can be reached from you server.
also make sure that you are using has a proper DNS server setup.

if you are sure that website is working ... try modifying the /etc/hosts file and add the website's IP for test purposes, then try to figure out why it doesn't solve the domain.

耳根太软 2024-09-09 12:59:33

该域无法解析为其 IP 地址。

如果您的 DNS 在本地运行,请尝试重新启动它。如果没有,请检查您的 DNS 或向 /etc/resolve.conf 添加不同的服务器(即名称服务器 8.8.8.8)。

您还可以将域添加为主机文件中的静态条目:

在 Linux 服务器上,使用以下命令将 DNS 信息添加到 /etc/hosts 文件中:

echo '127.0.0.1 www.otherdomain.com' >>> /etc/hosts

...其中 127.0.0.1 是您网站的 IP 地址,www.otherdomain.com 是您使用的域名。

您可以使用 nslookup 查找任何域的 IP 地址,即

nslookup www.otherdomain.com

The Domain can not be resolved to it's IP address.

If you have your DNS running local, try restarting it. If not, check your DNS or add a different server to /etc/resolve.conf (i.e. nameserver 8.8.8.8).

You can also add the domain as a static entry in your hosts file:

On your linux server add the DNS information to your /etc/hosts file using:

echo '127.0.0.1 www.otherdomain.com' >> /etc/hosts

…where 127.0.0.1 is the IP address of your website and www.otherdomain.com the domain name your using.

You can find the IP address of any domain using nslookup, i.e

nslookup www.otherdomain.com

短叹 2024-09-09 12:59:33

我在使用 CiviCRM 地理编码时遇到了这个问题!像 Shehi 建议的那样重新启动 Apache 解决了这个问题。

I was running into this issue with CiviCRM geocoding! Restarting Apache like Shehi recommended fixed the problem.

别挽留 2024-09-09 12:59:33

检查您的互联网连接。如果互联网出现故障,则会出现此错误。

check your internet connection. If the internet is down, this error occurs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文