Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an EC2 instance where Laravel 5 app is hosted. The DB is Amazon Aurora RDS. The app has been running fine for months. But this morning the API was unreachable. Everything else works apart from any calls to the API that uses DB. Other calls are serving fine. The error was recorded as:

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

But I could connect to the same DB from MySQL Workbench etc using the same exact details and nothing has changed in the app files in the meantime.

I restarted the Nginx and the problem is solved straight away and everything resumed to normal.

I still don't know what happened. Anyone could educate me on this as I am not sure if the problem can come back again randomly and how to stop that from happening.

like image 696
James Avatar asked Mar 21 '17 11:03

James


4 Answers

Same problem here on AWS EC2 with Ubuntu 14.04. Unattended upgraded last night :

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

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

Please click on "This bug affects me" to prioritize the fix on ubuntu side.

like image 52
guillaumeblachon Avatar answered Oct 18 '22 05:10

guillaumeblachon


They've issues a fix. See this link and the instructions at the bottom for your distro. https://www.ubuntu.com/usn/usn-3239-2/

like image 2
Joshua Ziering Avatar answered Oct 18 '22 04:10

Joshua Ziering


I am experiencing the exact same issue. Ubuntu 16.04, PHP and Drupal - just started this morning. I have been reloading apache on an off all morning and that temporarily resolves it:

service apache2 reload

But that doesn't permanently fix it and it has come back a couple of times again.

like image 1
Justin DeMaris Avatar answered Oct 18 '22 04:10

Justin DeMaris


We just experienced the same today. We are running Drupal 7 on a Ubuntu 16.04 box with PHP 7.0, nginx in EC2 connecting to an RDS instance.

We do have unattended upgrades enabled and the following was upgraded this morning:

Start-Date: 2017-03-21 06:13:56 Commandline: /usr/bin/unattended-upgrade 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-support:amd64 (2.23-0ubuntu3, 2.23-0ubuntu6), libfreetype6:amd64 (2.6.1-0.1ubuntu2, 2.6.1-0.1ubuntu2.1) End-Date: 2017-03-21 06:14:00

The solution was to restart nginx and PHP:

sudo service nginx restart
sudo service php7.0-fpm restart
like image 1
direct Avatar answered Oct 18 '22 05:10

direct