Not able to get client.list_database_names()

In “mongoclient” i have successfully get access of my cluster and also get result of “client.stats
But While i try to get database list using “client.list_database_names()” at that time it throw error : “OperationFailure: Authentication failed.”
here i have attached screen-shot of it.
Can any one help me out with it?
@kanikasingla can you please help me out in this too?

Please check the username password again to confirm as Authentication error is related to login credentials or authSource only.


but the username and password are correct. and i got connection ticket also

The drivers don’t actually trigger any auth mechanism when you create a MongoClient but only when they actually begin performing operations.
This is desirable since you don’t want an idle driver to hold on to a connection (consume unnecessary resources) or start a needless connection.

So, please share the connection string you are using, it might be any special character or double quotes.


this is the connection string that i am using

and i also try this one

There are username and password missing. Please try using with username and password.
It should be something like this:



Yes, i know, i removed it to publish here.

Are you able to connect to your cluster from the terminal/command line? Make sure the IP is whitelisted.
As when I tried connecting to the cluster, I am not able to do so.


yes, i did and run first “pytest -m connection” successfully.
but not able to run other test. I dont know why.

Hi @vishal_prajapati,

Please send the complete error report from jupyter notebook

1 Like