PHP link database error PHP_ network_ getaddresses: getaddrinfo failed: Name or service not known


SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

environment: thinkphp framework, Linux, ali cloud RDS database

ping link address normal:

error reporting process: access the background address, most are normal access, refresh 10-20 times may appear 1-2 error, not continuous error

solution 1:

restart php-fpm service

service php-fpm restart 

the original view:

special thanks to:

solution 2:

configure DNS resolution to

check DNS configuration: cat /etc/resolv.conf

I use the first solution, the second solution is temporarily useless, configuration method can be found on the Internet

Read More: