• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue php_network_getaddresses: getaddrinfo failed: Name or service not known

Timo002

Basic Pleskian
Hello,

I'm running Plesk Onyx 17.8.11 Update #7 on CentOs 7.4.1708.

When I run the PHP function file_get_contents() in my code, I'm getting an error:
Code:
file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/...

When running a php script from CLI, it is working fine.

What have I checked and done:
  1. I have 'allow_url_fopen' enabled (was already enabled)
  2. I tried to disable the firewall, no success
  3. I tried to disable selinux, no success
  4. I tried to add nameserver 8.8.8.8 and 4.4.4.4 to /etc/resolv.conf, did `service httpd restart`, no success
What else can I try?
 
@IgorG I added port 53 tcp to allow both outgoing and incomming. Doesn't work either.

The strange thing is dat from CLI this works fine, but not when I run the command from the browser.
 
Same problem here after i added nameserver 127.0.0.1 to /etc/resolv and delete the old one. And ideas?
 
"getaddrinfo failed: Name or service not known" can have many different reasons, non only a closed port. Very frequent mistakes are malformed addresses in the function, e.g. "htp://" instead of "http://" or "http:// myaddress.com" instead of "http://myaddress.com" etc. First thing to check is whether a correct address is used.

Adding localhost as a nameserver only makes sense if there is actually a nameserver running on the machine and it can deliver the data that is requested. I think having localhost as the only nameserver in /etc/resolv is a bad idea.
 
Thanks for the fast reply. I thought so too, but when I entered the provider DNS server again, everything worked again.

Why localhost as the only nameserver in /etc/resolv is a bad idea? "Plesk's bind" is a full DNS server, or not? :S Is it not possible to use it as a normal DNS server?
 
Hello,

I'm running Plesk Onyx 17.8.11 Update #7 on CentOs 7.4.1708.

When I run the PHP function file_get_contents() in my code, I'm getting an error:
Code:
file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/...

When running a php script from CLI, it is working fine.

What have I checked and done:
  1. I have 'allow_url_fopen' enabled (was already enabled)
  2. I tried to disable the firewall, no success
  3. I tried to disable selinux, no success
  4. I tried to add nameserver 8.8.8.8 and 4.4.4.4 to /etc/resolv.conf, did `service httpd restart`, no success
What else can I try?
Any idea about this dns problem ? Thanks!
 
Back
Top