File () [function.file]: php_network_getaddresses: getaddrinfo failed: temporary name resolution failure

I got the following error when I get the contents from a 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 solve this problem?

+4
source share
4 answers

Citation:

If you are having problems with fopen ("url ..."), but you can run the "host" url 'in the shell window and get the correct search, that’s why ...

It made me bang my head against him all day - finally, I found the answer buried in the bug reports, but figured it really should be more prominent!

The problem arises when you are on an ADSL line with DHCP (for example, our office) ... When the ADSL modem is updated DHCP lease, you can also switch DNS servers that confuse apache (and therefore PHP) - this means that you cannot look for hosts from PHP, even if you can command line .... The short-term solution is to restart apache.

You will receive "php_network_getaddresses: Error getaddrinfo: temporary name resolution failure in ..." messages as symptoms. Restart apache and they are gone :-)

Simon

Simon's comment on php.net

+24
source

make sure the website is accessible from your server. also make sure that you are using the proper DNS server setting.

if you are sure that the website is working ... try changing the / etc / hosts file and adding the IP address of the website for testing, and then try to find out why it does not resolve the domain.

+2
source

A domain cannot be resolved to its IP address.

If your DNS is running locally, try restarting it. If not, check your DNS or add another server to /etc/resolve.conf (for example, the name server is 8.8.8.8).

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

On your linux server, add the DNS information to the / 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 site and www.otherdomain.com is the name of your domain.

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

nslookup www.otherdomain.com

+2
source

I ran into this problem with CiviCRM geocoding! Restarting Apache, such as Shehi, recommended fixing the problem.

+1
source

Source: https://habr.com/ru/post/1310460/


All Articles