I am setting up a MongoDB replica set using EC2's image: https://aws.amazon.com/marketplace/pp/B00CO7AVMY/ref=dtl_recsim_B007IBMJPI_B00CO7AVMY_3

MongoDB version 2.6.5

I have managed to set up replicaset by not enabling "auth=true" in my config file.

I went ahead to add "auth=true" back into my config file and restarted mongodb on all 3 of my instances.

sudo service mongod restart

After restarting, I got into mongo shell and it is displaying


I am unable to run rs.status() because I don't have a PRIMARY.

 "errmsg" : "not authorized on admin to execute command { replSetGetStatus: 1.0 }"
  • Can you share the config file?
    – Antonios
    Nov 25, 2014 at 10:31

1 Answer 1


When you enable authentication you must also specify (at the very least) a keyfile also (see step 1 in the procedure for enabling auth), setting auth=true without a keyfile will mean that the mongod processes will not be able to authenticate with each other (this is what the keyfile is used for). Hence they cannot communicate, elect a primary, respond to heartbeats etc.

Follow the guide/docs linked above to create and configure a keyfile and your replica set should come up and elect a primary without an issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.