Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoError: user is not allowed to do action [listIndexes] on [DB.$cmd]

My API code is using the latest Mongoose 5.0.11 with the proper Mongo 3.4 connection string to connect to the free Atlas service.

mongodb://someadmin:<PASSWORD>@ascatlas-shard-00-00-6fake.mongodb.net:27017,ascatlas-shard-00-01-6fake.mongodb.net:27017,ascatlas-shard-00-02-6fake.mongodb.net:27017/DB?ssl=true&replicaSet=ascatlas-shard-0&authSource=admin

When it does this, the initial connection works properly, but then errors out with a permissions problem being unable to list the indexes on the collection in the "DB database". The user credentials I'm connecting with is the Atlas Admin, so not sure what other permissions I can provide. Any ideas?

profile:mongoose MongoDB connection established +5s
profile:mongoose profiles ensureIndex { identityID: 1 } { unique: 1, background: true } +5ms

/API-User/node_modules/mongoose/lib/utils.js:423
        throw err;
        ^
MongoError: user is not allowed to do action [listIndexes] on [DB.$cmd]
    at queryCallback (/API-User/node_modules/mongodb-core/lib/cursor.js:223:25)
    at /API-User/node_modules/mongodb-core/lib/connection/pool.js:541:18
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
like image 962
David Tesar Avatar asked Sep 20 '25 17:09

David Tesar


1 Answers

Seems that the user has no permission to listIndexes As per the documentation

Required Access The user executing the command requires either find privileges on the system.indexes collection or the listIndexes privilege action. At a minimum, the read built-in role provide the requisite permissions.

like image 180
Graciano Avatar answered Sep 22 '25 07:09

Graciano