Lecture: MongoClient - Error for client.list_database_names

Hi,

Tried to follow the lecture typing the code using jupyter.

I got OperationFailure (Authentication Error) when I tried to run:

client.list_database_names()

I have no problem running client.stats and got the output like those in the video.
I also passed the ticket: connection.

Not sure why I have authentication error.

Thanks

Try running the cells starting from the top, and also, check your internet connections.
Check your connections to MongoAtlas as well.

This time I got timed out, maybe I am trying at work.
Should I remove “access from anywhere” for the IP whitelist and use get current IP address when I am at home or work?

I tried using command line and it also gave me timed out error. Not sure if there are problems with my installation of Anacoda3. Please see the scripts in the screenshot below after the yellow highlight.

Thanks

Can you connect to port 27017 on the target host using netcat or nc? Can you ping the target host?

It works now. I disconnected and reconnected everything again.
Thanks!

I’m getting the same error attempting the same operation. I went the next step and replicated this behavior running the same commands via a .py file in PyCharms, with the same results. I’m clearly authenticating as the client is successfully created and returns stats, but can’t run anything that returns data from a db. I also tried another user, setting it up as admin, to no avail. I am able to use the same credentials and run ‘show dbs’ and various queries via mongo shell without error.

@wini_mongo, did you ever determine the root cause of this issue for you?

Hi @Mark_82375,

To help us debug the issue, please send the screenshot of the error you are seeing. Is it the client.list_database_names or Timed Out error?

Kanika

Here you go. I retried it many times, but I got the same error on first try.

I got it working. The connect I changed connectstring #1 to #2 and #2 worked. Obviously there are some details needed that #1 didn’t have.

#1 (fail) Original from Jupyter Notebook provided with the course:

  • uri = “mongodb+srv://’ + username + ‘:’ + password + '@mflix-wmybu.mongodb.net/test”
    #2 (success) with added params as provided by Atlas
  • uri = ‘mongodb+srv://’ + username + ‘:’ + password + ‘@mflix-wmybu.mongodb.net/test?retryWrites=true&w=majority’
1 Like