• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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