PDOException: SQLSTATE [HY000] [2002] php_network_getaddresses: getaddrinfo failed: name or service unknown

I have an EC2 instance where the Laravel 5 application is hosted. The database is Amazon Aurora RDS. The application works fine for several months. But this morning the API was unavailable. Everything else works regardless of the API calls using the database. Other calls serve a fine. The error was written as:

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

But I could connect to the same database from MySQL Workbench, etc., using the same exact data, and nothing has changed in the application files in the meantime.

I restarted Nginx, and the problem was resolved immediately, and everything resumed to normal.

I still don’t know what happened. Anyone could educate me on this, since I'm not sure that the problem can come back again randomly and how to stop it.

+6
source share
6 answers

Same issue here on AWS EC2 with Ubuntu 14.04. Updated yesterday:

2017-03-21 03: 42: 53,570 INFO Packages to be updated: libc-bin libc-dev-bin libc6 libc6-dev libfreetype6 libfreetype6-dev locales multiarch-support

Just created case on ubuntu error tracker: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1674733

Please click "This error affects me" to determine the priority on the ubuntu side.

+4

. Ubuntu 16.04, PHP Drupal - . :

service apache2 reload

, .

+1

20 Ubuntu DNS - , Canonical ( Ubuntu), DNS , , :

https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1674532

CMS / / , API- / , :

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed:    No address associated with hostname

Could not resolve host: downloads.wordpress.org

cURL error 6: Could not resolve host: example.com in....

, Canonical , , . DNS-, , , . DNS , :

sudo apt-get update
sudo apt-get upgrade

, , . :

# sudo dpkg -l | grep "GNU C Library" | awk '{print $3}'

Ubuntu 16.X, , :

# sudo dpkg -l | grep "GNU C Library" | awk '{print $3}'
2.23-0ubuntu7
2.23-0ubuntu7
2.23-0ubuntu7

Ubuntu 14.X, , :

# sudo dpkg -l | grep "GNU C Library" | awk '{print $3}'
2.19-0ubuntu6.11
2.19-0ubuntu6.11

, , .

+1

. Drupal 7 Ubuntu 16.04 PHP 7.0, nginx EC2, RDS.

, :

: 2017-03-21 06:13:56 :/usr/bin/unattended-upgrade : libc6: amd64 (2.23-0ubuntu3, 2.23-0ubuntu6), locales: amd64 (2.23-0ubuntu3, 2.23-0ubuntu6), libc-bin: amd64 (2.23-0ubuntu3, 2.23-0ubuntu6), multiarch: amd64 (2.23) -0ubuntu3, 2.23-0ubuntu6), libfreetype6: amd64 (2.6.1-0.1ubuntu2, 2.6.1-0.1ubuntu2.1) : 2017-03-21 06:14:00

nginx PHP:

sudo service nginx restart
sudo service php7.0-fpm restart
0

Debian 2.24-11+deb9u4 .

0

Source: https://habr.com/ru/post/1015904/


All Articles