How to connect via config file in mongodb
Solution


To avoid the error like: not master and slaveOk = false need always using the command: rs.slaveOk(). 
To avoid typing rs.slaveOk() every time need to add rs.slaveOk() in .mongorc.js file check here and here
More detail information.