Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

338
Views
Mongodb Node JS serverStatus always returns false

I'm new to mongo and am messing around with the admin serverStatus. For me, it always returns false when I am expecting an object. I'm running mongod with auth enabled. Are there specific user privs that are required? I can't find much documentation other than what is supplied by the API docs from the nodejs drivers or the mongodb manual.

MonogDB 3.4 NodeJS drivers 2.2

var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://user:pass@localhost:27017/test?authMechanism=DEFAULT&authSource=test', function(err, db) {
  var adminDB = db.admin();
  adminDB.serverStatus(function(err, status) {
    console.log(status);
    db.close();
  });
});

Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I found the answer. With auth enabled databases you need to grant a role to the executing user with the serverStatus action.

db.createRole(
   {
     role: "mongostatRole",
     privileges: [
       { resource: { cluster: true }, actions: [ "serverStatus" ] }
     ],
     roles: []
   }
)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!