title: Mongo: Bad Auth Authentication failed.
body: <p>I am trying to do a <strong>mongoose</strong> connection from <strong>Mongo Atlas</strong>. I have a cluster <code>ayman</code> and I am trying to connect it from Terminal(Ubuntu 18).
  It says that I have successfully connected to the shard, but it says authentication failed. I am giving credentials defined as SCRAM on Mongo Atlas. <a href="https://i.stack.imgur.com/cEAs4.png" rel="nofollow noreferrer">Mongo Security Page</a></p>
  
  <pre><code>mongo "mongodb://ayman-shard-00-00-xxzs1.mongodb.net:27017,ayman-shard-00-01-xxzs1.mongodb.net:27017,ayman-shard-00-02-xxzs1.mongodb.net:27017/test?replicaSet=ayman-shard-0" --ssl --authenticationDatabase admin --username aymanpatel --password &lt;PASSWORD&gt;
  MongoDB shell version v3.6.3
  connecting to: mongodb://ayman-shard-00-00-xxzs1.mongodb.net:27017,ayman-shard-00-01-xxzs1.mongodb.net:27017,ayman-shard-00-02-xxzs1.mongodb.net:27017/test?replicaSet=ayman-shard-0
  2018-10-07T09:40:34.288+0530 I NETWORK  [thread1] Starting new replica set monitor for ayman-shard-0/ayman-shard-00-00-xxzs1.mongodb.net:27017,ayman-shard-00-01-xxzs1.mongodb.net:27017,ayman-shard-00-02-xxzs1.mongodb.net:27017
  2018-10-07T09:40:34.336+0530 I NETWORK  [thread1] Successfully connected to ayman-shard-00-01-xxzs1.mongodb.net:27017 (1 connections now open to ayman-shard-00-01-xxzs1.mongodb.net:27017 with a 5 second timeout)
  2018-10-07T09:40:34.339+0530 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to ayman-shard-00-02-xxzs1.mongodb.net:27017 (1 connections now open to ayman-shard-00-02-xxzs1.mongodb.net:27017 with a 5 second timeout)
  2018-10-07T09:40:34.393+0530 I NETWORK  [thread1] Successfully connected to ayman-shard-00-00-xxzs1.mongodb.net:27017 (1 connections now open to ayman-shard-00-00-xxzs1.mongodb.net:27017 with a 5 second timeout)
  MongoDB server version: 3.6.8
  2018-10-07T09:40:34.517+0530 I NETWORK  [thread1] Marking host ayman-shard-00-00-xxzs1.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node ayman-shard-00-00-xxzs1.mongodb.net:27017: bad auth Authentication failed.
  2018-10-07T09:40:34.562+0530 I NETWORK  [thread1] Successfully connected to ayman-shard-00-01-xxzs1.mongodb.net:27017 (1 connections now open to ayman-shard-00-01-xxzs1.mongodb.net:27017 with a 0 second timeout)
  2018-10-07T09:40:34.609+0530 I NETWORK  [thread1] Marking host ayman-shard-00-01-xxzs1.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node ayman-shard-00-01-xxzs1.mongodb.net:27017: bad auth Authentication failed.
  2018-10-07T09:40:34.655+0530 I NETWORK  [thread1] Successfully connected to ayman-shard-00-02-xxzs1.mongodb.net:27017 (1 connections now open to ayman-shard-00-02-xxzs1.mongodb.net:27017 with a 0 second timeout)
  2018-10-07T09:40:34.705+0530 I NETWORK  [thread1] Marking host ayman-shard-00-02-xxzs1.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node ayman-shard-00-02-xxzs1.mongodb.net:27017: bad auth Authentication failed.
  2018-10-07T09:40:34.731+0530 I NETWORK  [thread1] Marking host ayman-shard-00-00-xxzs1.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node ayman-shard-00-00-xxzs1.mongodb.net:27017: bad auth Authentication failed.
  2018-10-07T09:40:34.731+0530 E QUERY    [thread1] Error: can't authenticate against replica set node ayman-shard-00-00-xxzs1.mongodb.net:27017: bad auth Authentication failed. :
  DB.prototype._authOrThrow@src/mongo/shell/db.js:1608:20
  @(auth):6:1
  @(auth):1:2
  exception: login failed
  </code></pre>
  
  <p>Cluster name: ayman</p>
  
  <p>Username: aymanpatel</p>
  
  <p>MongoDB shell version v3.6.3</p>