I’ve an App of a Docker Laravel installation that communicate with two Vue.js apps via mySql database. When I call the query from the frontend apps I get in console the following error:
{"errors":[{"message":"Internal server error","extensions":{"category":"internal"},"locations":[{"line":2,"column":3}],"path":["clients"]}],"extensions":{"lighthouse_subscriptions":{"version":2,"channel":null}}}
Checking the laravel.log on the DigitalOcean App I see this error:
[2022-11-19 08:12:40] production.ERROR: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `user_type` like CLIENT) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `user_type` like CLIENT) at /workspace/vendor/laravel/framework/src/Illuminate/Database/Connection.php:759)
My App settings has the App Spec variables like that
- key: DB_DATABASE
scope: RUN_TIME
value: xxxxx
- key: DB_PORT
scope: RUN_TIME
value: "3306"
- key: DB_HOST
scope: RUN_TIME
value: 127.0.0.1
- key: DB_USERNAME
scope: RUN_TIME
value: xxxxxxx
- key: DB_PASSWORD
scope: RUN_TIME
value: xxxxxxx
on the Laravel side, the config/database.php
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'xxxxxx'),
'username' => env('DB_USERNAME', 'xxxxxx'),
'password' => env('DB_PASSWORD', 'xxxxxx'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
on the Vue.js side
const apolloClient = new ApolloClient({
link: ApolloLink.from([
pusherLink,
createUploadLink({
uri: 'DigitalOcenAppURI/graphql',
}),
]),
cache,
});
I wonder where is the problem. Maybe mysql is not installed on the DigitalOcean app??
Thank you for the help
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
I would recommend not running MySQL inside the App Platform itself, as the storage there is ephemeral storage. This means that you will lose your data every time you deploy a new version of your app.
What you could do is to use a Managed MySQL database and configure your environment variables so that your Laravel app connects to the managed database cluster and persists your data correctly.
You can follow the steps here on how to deploy Laravel to the App Platform:
Hope that this helps!
Best,
Bobby