jvbalcita
2 months ago
448
6
Forge

500 Internal Server Error on Laravel Forge 2nd Database

Posted 2 months ago by jvbalcita

We're actually deploying our Laravel application now in Forge. But we are getting a 500 Internal Server Error when fetching the data from the 2nd database. We have public and private API from that database and both returns 500 error.

We tested both locally and it works fine.

Also tried using postman to access the API from the main database and it is returning the data fine. But for the 2nd database same issue.

Here's our .ENV file

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=schoolname
DB_USERNAME=root
DB_PASSWORD=

DB_CONNECTION_SECOND=mysql
DB_HOST_SECOND=127.0.0.1
DB_PORT_SECOND=3306
DB_DATABASE_SECOND=SCHL0000001
DB_USERNAME_SECOND=root
DB_PASSWORD_SECOND=

And the 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', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            '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'),
            ]) : [],
        ],

        'SCHL0000001' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST_SECOND'),
            'port' => env('DB_PORT_SECOND'),
            'database' => env('DB_DATABASE_SECOND'),
            'username' => env('DB_USERNAME_SECOND'),
            'password' => env('DB_PASSWORD_SECOND'),
            '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'),
            ]) : [],
        ],

We are using DigitalOcean managed database. We also tried using the local database of Forge. Same issue.

Migrations work fine. We checked both database and all have records inside. Our problem is just it's not getting anything from the 2nd database.

Is there a bearing using the MYSQL 8 in DigitalOcean? We tried using MySQL 5.7

Hope someone can help us :(

Please sign in or create an account to participate in this conversation.