SQLSTATE[HY000] [2002] Name or service not known

Viewed 39

We host our Laravel API on EC2, and it connects to an Aurora Global database. Specifically a MySQL cluster that is split into a writer, and a reader which autoscales.

The problem we have currently, is that when the cluster scales in and one of the readers terminates, we start getting the error shown below:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for <Cluster Endpoint> failed: Name or service not known (<SQL Query>) at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:759)

Now for the weird parts:

  • It only lasts for a few minutes
  • We'll get the error on one query, thenit'll work, then it won't, etc.
  • It happens to all types of queries, selects, inserts, queries running in jobs, etc.
  • It resolves itself with no input from

We've currently gone down the rabbit hole of AWS DNS Quota limits, and that doesn't seem to be the case (could be wrong). We've also spoken to EC2 and RDS support and they've found no issues with their services.

Any help is very much appreciated! If you want any more information, please let me know.

1 Answers

In the end a minor update to the RDS cluster resolved the issue.

Related