Cannot connect from machine to mysql

So I have three machines:
2 x Laravel app
1 x MySQL

MySQL machine is up and running and I can SSH into the Laravel machines and connect to the MySQL machine via the internal name, IE [mysql-machine-name].internal on port 3306.

However, I am trying to redeploy the Laravel app machines (as I have changed them from using LiteFS to using MySQL which is another story).

The dockerfile works until we get to the command:
php artisan migrate --force

At this point it tries to connect to the database and fails with:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for sslv2-mysq
0.364 l-deploy.internal failed: Name or service not known (Connection: mysql, SQL
0.364 : select exists (select 1 from information_schema.tables where table_schema
0.364 = ā€˜ssl_dbā€™ and table_name = ā€˜migrationsā€™ and table_type in (ā€˜BASE TABLEā€™,
0.364 ā€˜SYSTEM VERSIONEDā€™)) as exists)
0.364
0.364
0.364 In Connector.php line 66:
0.364
0.364 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for sslv2-mysq
0.364 l-deploy.internal failed: Name or service not known
0.364
0.364
0.364 In Connector.php line 66:
0.364
0.364 PDO::__construct(): php_network_getaddresses: getaddrinfo for sslv2-mysql-d
0.364 eploy.internal failed: Name or service not known

So this looks like the Laravel machine cannot access the MySQL machine using the ā€œsslv2-mysql-deploy.internalā€ host name.

Yet, if I comment those Laravel migration scripts out it builds and deploys and then I can SSH into the machine and connect to the MySQL instance using the same internal name.

Its as if the internal name is not available when the migration starts.

Any ideas?

Added IP6 to MySQL instance and tried that instead, still won;t connect

Hiā€¦ The builders donā€™t have access to the internal network, :cactus:, last I heard.

The recommended work-around is to use release_command instead for migrations.

Hope this helps!

1 Like

Top man!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.