Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jestins's avatar

Laravel 5.2 : Authentication Failed when trying to connect to MongoDB

I'm getting the following error while I'm connecting to mongo using Jenssegers MongoDB plugin.

AuthenticationException in Find.php line 219:
Authentication failed.

Config:

$mongo_db_credential = [
            'driver' => 'mongodb',
            'host' => env('MONGO_HOST', 'localhost'),
            'port' => env('MONGO_PORT', '27017'),
            'database' => env('MONGO_DATABASE', 'test'),
            'username' => env('MONGO_DB_USERNAME', 'admin'),
            'password' => env('MONGO_DB_PASSWORD', 'pass'),
            'options'  => [
                'database' => 'admin', // sets the authentication database required by mongo 3
            ]
        ];

Installed php extension version : 1.3.0-dev

In local its working fine, In server only I have this issue.

Local php extension version : 1.2.9

Is it because of the mongo driver.?

0 likes
0 replies

Please or to participate in this conversation.