Watch keynotes and sessions from, our virtual developer conference.

VScode extension error: not master and slaveOk=false

Hit here ,

I have been using the RoboMongo for exploring the diff Mongo server for work. I tried to configure the new Mongo extension for vscode. During the connection config thing went well and got a green. But when I try to list the db by double-clicking the connection profile got the following error.

Unable to list databases: not master and slaveOk=false

I am not sure where I can run this. Since I don’t see a default console as I do in the roboMongo

Hello @Khalifa_Ali_Al-Thani :wave: welcome to the forum!

Based on the error message I assume that you try to connect to a secondary without having reads allowed.

To fix this follow this steps (I write this assuming you are using VS Code)

  1. connect to the db
  2. in VS Code press F1 and get the “command filter”
  3. Select and run the command MongoDB: Launch MongoDB Shell
  4. flip to the shell window which opened at the bottom
  5. run the comand rs.slaveOk() in the shell this will allow reads from Secondaries

This should fix the error message you have posted.

Hope that helps