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

5

5

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?

Carbrey answered 21/5, 2010 at 8:31 Comment(0)
H
25

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

Hippy answered 12/11, 2010 at 21:50 Comment(2)
What exactly does but you can run 'host url' in a shell window mean? Like running ping <site url> from that site's server?Treble
@doublejack: it means open Terminal in any Linux and type, e.g. "host google.com" :PHippy
C
2

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.

Cutter answered 21/5, 2010 at 10:18 Comment(1)
yes, website is running properly. since last 4-5 days its given this warning : file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in %url% on line %lineno% I did not find hosts file in etc in server. Please tell me how to create thatCarbrey
S
2

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

Sensate answered 22/5, 2010 at 18:1 Comment(1)
Thank You, my website is running properly. The problem is that emails are not going from my website and when i use file("otherdomain.com") it gives an error file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution And when I use file("otherdomainIP.com") if works fine. Please help me to find out this. Thanks,Carbrey
S
2

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

Samuel answered 3/5, 2012 at 11:6 Comment(0)
T
0

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

Tunable answered 4/6, 2022 at 11:44 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewWaterman

© 2022 - 2024 — McMap. All rights reserved.