title: MongoDB - authentication failed
body: <p>I'm using Pymongo to connect to the a read only instance of my MongoDB replica set.</p>
  <p>The problem with my code is that sometimes the query goes through, while sometimes, apparently for no reason and with the same code, i get an <code>Authentication failed error</code>:</p>
  <pre><code>pymongo.errors.OperationFailure: Authentication failed., full error: {'ok': 0.0, 'errmsg': 'Authentication failed.', 'code': 18, 'codeName': 'AuthenticationFailed', ....}
  </code></pre>
  <p>I don't understand why is this happening, since i'm performing very basic operations and my connection string should be alright.</p>
  <pre><code>import pymongo
  from pymongo import MongoClient
  
  client = MongoClient('mongodb://root:MY-PASSWORD@MY-IP:27017/?authSource=MY-DB&amp;replicaSet=replicaSetOne')
  db = client.marketdata
  
  cursor =  db['MYCOL'].find({'unix': {'$gte': 1611874500}})
  
  for document in cursor:
      print(document)
  </code></pre>
  <p>Any kind of advice is appreciated.</p>