php_network_getaddresses: getaddrinfo failed

Problems with the Linux version of XAMPP, questions, comments, and anything related.

php_network_getaddresses: getaddrinfo failed

Postby indapoint » 10. July 2009 11:52

Hello

I have installed XAMPP on my Linux server (Fedora 11) and some of the specific PHP functions are not working like file() and curl lib. When I try to use these functions it gives me an error like

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


On my php.ini allow_url_fopen set to on

Host file and networking is ok on server, if we try to ping any domain (e.g. http://www.google.com) from shell/command seems working fine. However PHP is not able to access same domain.
Please help
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby Nobbie » 10. July 2009 12:18

Probably a firewall is blocking the Apache process or similar.
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

Re: php_network_getaddresses: getaddrinfo failed

Postby indapoint » 10. July 2009 13:12

I have deactivated firewall before to solve this but it did not work
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby glitzi85 » 10. July 2009 13:24

What's the output of an nslookup on the shell? Could you also try to execute the same nslookup command via the PHP-Function passthru(). Also check the entries in /etc/resolv.conf.

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: php_network_getaddresses: getaddrinfo failed

Postby indapoint » 14. July 2009 12:43

Hi

here is the output from shell
Code: Select all
$ nslookup http://www.google.com
Server:         192.168.0.2
Address:        192.168.0.2#53

Non-authoritative answer:
http://www.google.com  canonical name = http://www.l.google.com.
http://www.l.google.com        canonical name = www-notmumbai.l.google.com.
Name:   www-notmumbai.l.google.com
Address: 64.233.189.99
Name:   www-notmumbai.l.google.com
Address: 64.233.189.104
Name:   www-notmumbai.l.google.com
Address: 64.233.189.147


Here is output from PHP passthru
Code: Select all
Server: 192.168.0.2 Address: 192.168.0.2#53 Non-authoritative answer: http://www.google.com canonical name = http://www.l.google.com. http://www.l.google.com canonical name = www-notmumbai.l.google.com. Name: www-notmumbai.l.google.com Address: 64.233.189.147 Name: www-notmumbai.l.google.com Address: 64.233.189.99 Name: www-notmumbai.l.google.com Address: 64.233.189.104


Does this give any idea ?
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby glitzi85 » 14. July 2009 20:37

What did you mean with:
However PHP is not able to access same domain.

?

And what domain do you try to open with file()?

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: php_network_getaddresses: getaddrinfo failed

Postby indapoint » 15. July 2009 10:36

This means that I can ping any domain from command line on same server but while I try to access same domain by PHP, using file() or CURL it gives me an error as I posted.

It does not work with any domain and gives an error as I posted here (Above).
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby glitzi85 » 15. July 2009 12:46

OK, now it is clear what you mean.

The problem is, that this error message can be caused by a lot of things. Mostly when the target is not reachable, but that doesn't sound like your problem, as you get the error with all domains. Other common problem is the DNS system. To verify this, could you please post the file /etc/resolv.conf. In this file you should find some IPs. Could you please execute this command with every IP:

Code: Select all
dig @IP google.com

alternative, if you do not have dig installed run this command:
Code: Select all
nslookup google.com IP


glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: php_network_getaddresses: getaddrinfo failed

Postby indapoint » 15. July 2009 13:05

Hello I just have follwoing details on my file /etc/resolv.conf
Code: Select all
# Generated by NetworkManager
nameserver 192.168.0.1
nameserver 192.168.0.2
 


As I wrote before, everything is working OK with all users on Linux, I mean Internet is working fine, emails are working fine on Linux machine, it is only issue when PHP tries to access Internet
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby glitzi85 » 15. July 2009 13:31

indapoint wrote:Hello I just have follwoing details on my file /etc/resolv.conf
Code: Select all
# Generated by NetworkManager
nameserver 192.168.0.1
nameserver 192.168.0.2
 

Could you try the command i posted with both IPs please.

indapoint wrote:As I wrote before, everything is working OK with all users on Linux, I mean Internet is working fine, emails are working fine on Linux machine, it is only issue when PHP tries to access Internet

Your Linux normally tries the first entry in the List, if there is no response from the DNS server, then it tries the next and so on. PHP only checks the first one, if it gets no response, you get the error message
Code: Select all
file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in ….

So the first entry in this file MUST be an valid DNS Server!

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: php_network_getaddresses: getaddrinfo failed

Postby indapoint » 16. July 2009 08:18

Code: Select all
[root@xxxxxx~]# nslookup 192.168.0.1
Server:         192.168.0.2
Address:        192.168.0.2#53

** server can't find 1.0.168.192.in-addr.arpa.: NXDOMAIN

[root@xxxxx~]# nslookup 192.168.0.2
Server:         192.168.0.2
Address:        192.168.0.2#53

** server can't find 2.0.168.192.in-addr.arpa.: NXDOMAIN

I think there is something wrong here , what does this
Code: Select all
** server can't find 2.0.168.192.in-addr.arpa.: NXDOMAIN
mean and what is
Code: Select all
2.0.168.192 and 1.0.168.192
?

Thanks
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby indapoint » 16. July 2009 09:26

SOLVED
Hey
Finally I could solve the issue by changing my DNS entry, initially I put my router IP which was local and then I changed to live IPs (The one provided by my ISP) and it worked.

However, question still remains unanswered, If there was a problem in DNS then why it was working from shell ? It was only PHP which had an issue with that.

Thanks !!
indapoint
 
Posts: 7
Joined: 10. July 2009 11:44

Re: php_network_getaddresses: getaddrinfo failed

Postby glitzi85 » 16. July 2009 14:14

indapoint wrote:and what is
Code: Select all
2.0.168.192 and 1.0.168.192

http://en.wikipedia.org/wiki/Reverse_DNS_lookup

I am not absolutely sure what the problem here is. I am also not really sure how nslookup exactly works, but i think the PHP function throws much faster an error.

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 6 guests