MongoError: cannot do queries on admin in atlas

I had the exact same issue. Seems like its a new one.

Heres my connection string that now works

mongoose.connect('mongodb://USERNAME:PASSWORD@myShard-shard-00-00-lbofd.mongodb.net:27017,myShard-shard-00-01-lbofd.mongodb.net:27017,myShard-shard-00-02-lbofd.mongodb.net:27017/MYDBNAME?ssl=true&replicaSet=myShard-shard-0&authSource=admin');

To create a new DB I used MongoDB Compass. Copy the connection string from the Atlas site(the longer one - 3.4 I believe), when you open mongodb compass it will recognize that there is a connection string in your clipboard (OSX) and will allow you to populate the connection for Compass with a simple click. You can create a new Database from there (Click on MyCluster at top left - then Create Database. Put the name of the new db in the bolded MYDBNAME in my connection string.

It did take a few refreshes to see new data.

I had much the same connection string as you (db name/shard different etc) - I was able to POST but not GET. POSTS didnt create error (but I could not find data I posted) and GET threw the same error as you got.


I just got this error after trying to switch from my paid Mongo Atlas cluster back to my free cluster. The solution for me ended up being blissfully simple:

In the URI, I changed /admin to the name of the free cluster's db or /test in my case.

String before fix:

"mongoURI": "mongodb+srv://<username>:<password>@cluster0-azhuz.mongodb.net/admin?retryWrites=true&w=majority"

String after fix:

"mongoURI": "mongodb+srv://<username>:<password>@cluster0-azhuz.mongodb.net/test?retryWrites=true&w=majority"