@fylzero First of all, thank you for your reply.
I'm not using forge. I've set the .env file to work with an instance of Amazon RDS. Most of the time it's used the right DB configuration. However, if I make multiple GET requests, sometimes I get this error. It's like for some reason Laravel can't find the correct cached settings (generated from the .env file) and uses the default value in the database.php.
This is the default mysql variable in the database.php file:
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
...
],
Whereas, these are my DB settings in the .env file:
DB_CONNECTION=mysql
DB_DATABASE=localguides
DB_PORT=3306
DB_HOST="xxx.xxx.eu-south-x.rds.amazonaws.com"
DB_USERNAME="vapor"
DB_PASSWORD="xxxxxxxxxx"