php DNS 设置错误,php_network_getaddresses: getaddrinfo failed Name or service not known, nslookup

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11802351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:08:38  来源:igfitidea点击:

Wrong DNS Settings, php_network_getaddresses: getaddrinfo failed Name or service not known, nslookup

phpapachednsping

提问by Maksym

The problem originally looked like this:

问题最初是这样的:

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home///ppk_hotweb.class.php on line 58

警告:file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home ///ppk_hotweb.class.php on line 58

I used cURL as well, it just returned null, that's it.. Both (file & cURL) were enabled.

我也使用了 cURL,它只是返回 null,就是这样.. 两个(文件和 cURL)都被启用了。

Tried file_get_contents('google.com')and it worked!

试过了file_get_contents('google.com'),成功了!

Why doesn't file_get_contents('domain.com.au')work then?

那为什么不起作用file_get_contents('domain.com.au')

So I started reading relevant stackoverflow posts and people say that this is a DNS settings issue.

所以我开始阅读相关的 stackoverflow 帖子,人们说这是 DNS 设置问题。

I tried the following:

我尝试了以下方法:

> # ping domain.com.au
ping: unknown host domain.com.au

What's wrong with the host? The site is live.

楼主怎么了?该网站已上线。

Also:

还:

# nslookup domain.com.au
Server: 203.16.60.
Address: 203.16.60.
#53

*** Can't find domain.com.au: No answer

# nslookup domain.com.au
服务器:203.16.60。
地址:203.16.60。
#53

*** 找不到 domain.com.au: 没有答案

and

> # dig domain.com.au

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <<>> domain.com.au
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52814
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;domain.com.au.          IN      A

;; AUTHORITY SECTION:
domain.com.au.   3600    IN      SOA     ns1.web24.net.au. dns.web24.net.au. 2012080201 7200 3600 604800 3600

;; Query time: 1 msec
;; SERVER: 203.16.60.***#53(203.16.60.3)
;; WHEN: Sat Aug  4 05:43:23 2012
;; MSG SIZE  rcvd: 92

I'll really appreciate any help! Thanks.

我真的很感激任何帮助!谢谢。

UPD: btw, just tried the Whois lookup...

UPD:顺便说一句,刚刚尝试了 Whois 查找...

domain.com.au is not available

domain.com.au 不可用

:(

:(

回答by drew010

The DNS server being used by your server may be using old cached DNS records since looking up that host works for me.

您的服务器使用的 DNS 服务器可能正在使用旧的缓存 DNS 记录,因为查找该主机对我有用。

My digresults also return a valid A record which yours doesn't appear to.

我的dig结果还返回一个有效的 A 记录,而您的结果似乎没有。

This probably won't change anything given the DNS issues, but

鉴于 DNS 问题,这可能不会改变任何事情,但是

file_get_contents('domain.com.au');

should be:

应该:

file_get_contents('http://domain.com.au');

Using the first option will try to locate a local file rather than using the httpwrapper.

使用第一个选项将尝试定位本地文件而不是使用http包装器。

If you have permission, try changing the name servers in your /etc/resolv.conffile to other nameservers.

如果您有权限,请尝试将/etc/resolv.conf文件中的名称服务器更改为其他名称服务器。

回答by Vahid Alvandi

you can use this command without https like bellow

您可以像下面这样在没有 https 的情况下使用此命令

 php -r "readfile('http://symfony.com/installer');" > symfony