Mongodb Atlas: not authorized on admin to execute command

I ended up asking this question to MongoDB University discussion board. In case anyone comes across this, this is apparently because I am using a free cluster.


This drove me insane... Turns out the standard link provided by MongoDB was trying to name my default database "admin". Change the link from

mongodb+srv://username:[email protected]/admin?retryWrites=true&w=majority 

to

mongodb+srv://username:[email protected]/test?retryWrites=true&w=majority

You can put any word in for test just not admin. Hope this helps!


I had the same issue when I was trying to connect to a cluster with Node.js version 3.0 or later and using the link below:

mongodb+srv://username:[email protected]/test?retryWrites=true

By selecting version 2.2.12 or later and using the link provided, everything went well

mongodb://username:[email protected]:27017,cluster0-shard-00-01-eoowo.mongodb.net:27017,cluster0-shard-00-02-eoowo.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true