Temporary failure in name resolution : Host name lookup failure [closed]

PHP is having trouble accessing either /etc/hosts or /etc/resolv.conf: there's a long standing issue in PHP related to this specific error. The fix is to try restarting Apache or whatever is invoking PHP, or to make sure /etc/hosts and /etc/resolv.conf are readable by what's invoking PHP.


I just experienced the same error and

service httpd restart

did the trick...


% dig @208.67.222.222 smtp.gmail.com +short
gmail-smtp-msa.l.google.com.
209.85.201.109
209.85.201.111
%

Now, try using Xdebug to see where the problem is exactly....

<?php
xdebug_start_trace('/tmp/lookup-trace.log');
$ip = gethostbyname('smtp.gmail.com');
xdebug_stop_trace();
die($IP);
?>

Anything good in the logs?