|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-01-20 18:20 UTC] skasun at tucson dot com
Description:
------------
We keep sporadically getting this error:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in [path to script] on line XX
It has nothing to do with DNS on the machine. I can have dns_get_record return a valid response on the exact same page as that error. It's also not consistent. getaddrinfo works 90% of the time, but randomly, without any changes to the machine or the scripts, it will give the above error.
Reproduce code:
---------------
$page=file_get_contents("http://google.com");
Expected result:
----------------
The contents of google.com gets put into $page
Actual result:
--------------
90% of the time, we get the expected result.. but then it will start failing and it may take several page reloads for it to start magically working again.
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in [path to script] on line XX
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
PHP doesn't do anything magic here. We are simply calling your system's getaddrinfo function. The code looks like this: if ((n = getaddrinfo(host, NULL, &hints, &res))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n)); } getaddrinfo() returns 0 on success. And as you can see from the code, the error is coming from your getaddrinfo() low-level call. That error message corresponds to an EAI_AGAIN error from the call. On my system the man page just says: EAI_AGAIN The name server returned a temporary failure indication. Try again later. So, I am not sure how to help you here. I see nothing wrong with the code as evidenced by the fact that it works most of the time for you. Can you check the logs of your dns server and see why you might be getting temporary failures there?