SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed when trying to connect to DigitalOcean Managed Database

175 views Asked by At

I'm trying to setup a Laravel 10 application on DigitalOcean with a Managed Database. I have an nginx server up and running on the droplet and can access the website by it's domainname. However I can't connect to the Managed Database as can be seen in the screenshot below when I try to migrate the tables:

enter image description here

What I have so far is:

These are the settings I use:

.env

enter image description here

Which come straight from the DO control panel:

enter image description here

/config/database.php

enter image description here

Location of the CA certificate;

enter image description here

The MySql client: enter image description here

Furhtermore I'm able login the mysql server inside the droplet and create database users and tables .

I really would appreciate any help on this. I'm currently kind of clueless after searching for hours on the internet.

1

There are 1 answers

0
Michel FW On

After very long searching and debugging I found that there were already database variables defined in /etc/environment.

I guess DigitalOcean puts it there when you create your droplet and have the "add a managed database" checkbox checked. However I ended up deleting it and creating another managed database.

So the database in my .env file in my application were overruled by the ones defined in the /etc/environment file.