I don't know what can cause this problem, nginx configs or php or anything else but :
I can not make connection when host value for these php functions listed below is set to FQDN like http://www.domain.com or www.domain.com but problem all goes away if i put hostname ip for instance 192.2.8.1 .
ex: @fsockopen($host, $port, $errno, $errstr, 10) won't establish connection when $host = "www.somedomain.com" successfully connects when $host = "192.2.2.1"
listed functions suffering form the same problem so far
- @fsockopen
- @file_get_contents
- phpmailer can't send email through SMTP when host is "www.somedomain.com" but succesfully send mail when host is "192.2.2.1"
all of those were working perfectly before i point my FQDN to my server and when i was testing
plus it all works both with ip and domain from my pc running wammp server and on same app, on same codes
i'm not 100% sure but i guess this problem raised after i pointed my domain and DNS to server ?!
Note : this case is related to server configs and i have provided php references to better describe the case
' downvoters can now relax, i have completely changed the description ' .
Best Answer
Ok ! Finally after a week struggling with this issue :
First of all it seems to be a very popular problem for a century !
https://bugs.php.net/bug.php?id=11058
https://www.google.com/search?hl=es&ie=UTF-8&oe=UTF-8&q=php+php_network_getaddresses%3A+getaddrinfo+failed&meta=&gws_rd=ssl
Some ppl have found individual solutions at their own but definitely it's not a PHP bug .
What this issue can cover :
--Things that can cause these problems-------------------------------------------------
[X]
First thing to check is to check your php.ini and make sure these attributes are enabled
[X]
Create a phpinfo() file [ phpinfofile.com just in case ] and check if these extensions are enabled
Especially for windows user running xammp or wammp by disabling PHP_OpenSSL extension you might be unable to connect through @fsockopen
[X]
Now the important part, is to go after resolv.conf Open your resolv.conf by running
and see what the result is, if it's something like[X]
Strongly make sure your /etc/resolv.conf is not a symlink pointing to some directories commonly at /run/resolvconf/ or etc .. you can run
If you have an ftp access go download your /etc/resolv.conf then rename the current one on your server to something line /etc/resolv.conf-----bk ( to have it just for backup ) and then upload the one you downloaded from your system to server /etc/
Or if you don't have access to ftp run these commands
In this case my issue was that !
[X]
Make sure your reslv.conf is accessible to all users
after running ls -la /etc/resolv.confThe result should be
[X]
Next Run
Find the dns-nameservers and make sure nameservers seem fine ( preferably put whatever nameservers that are on your /etc/resolv.conf file - ex: dns-nameservers 8.8.8.8 8.8.4.4
That's all that i've discovered for this issue so far , i tried it to be understandable for anyone, sorry for annoying references to things you well know
If anybody else have something more for this matter please share it .