andrescabana86 andrescabana86 - 3 months ago 75x
Node.js Question

Mongo Atlas: Connection authentication failed with custom databases

I am trying the Mongo Atlas Cloud. I create a cluster and i am trying a connection with the mongo shell: (same problem with mongo drivers)

mongo mongodb://***-cluster-shard-00-00-***,***-cluster-shard-00-01-***,***-cluster-shard-00-02-*******-Cluster-shard-0 --ssl --username ***** --password *****

this is the connection string in the documentation. And this is the error:

MongoDB shell version: 3.2.7
connecting to: mongodb://***-cluster-shard-00-00-***,***-cluster-shard-00-01-***,***-cluster-shard-00-02-******-Cluster-shard-0
2016-07-07T01:31:17.535-0300 I NETWORK [thread1] Starting new replica set monitor for ***-Cluster-shard-0/***-cluster-shard-00-00-***,***-cluster-shard-00-01-***,***-cluster-shard-00-02-***
2016-07-07T01:31:17.535-0300 I NETWORK [ReplicaSetMonitorWatcher] starting
2016-07-07T01:31:20.084-0300 E QUERY [thread1] Error: Authentication failed. :

exception: login failed

I can connect to the database only when i use admin database "/admin?" in the connection string.


I need to connect to a custom database with the console or mongo drivers.

PD: i protect my data with "***"


You authenticate with the admin database. From there you can switch the database.

When connecting using Mongo drivers, your connection string needs add the auth source: