I have been running a shell script that starts mongod instances on different machines, initializing them (the first machines) and adding them to a replica set (the others). The following is a summary of what I ran:

Machine 1 - mongod and initiate as primary by running rs.initiate()

Machine 2 - mongod and contact primary to run rs.add()

However, when I add the second mongod instance, the response was ok, but running rs.status() on primary it shows Machine 2 in STARTUP state

{ "_id" : 1, "name" : "Machine 2", "health" : 1, "state" : 0, "stateStr" : "STARTUP", "uptime" : 30, "optime" : { "ts" : Timestamp(0, 0), "t" : NumberLong(-1) }, "optimeDurable" : { "ts" : Timestamp(0, 0), "t" : NumberLong(-1) }, "optimeDate" : ISODate("1970-01-01T00:00:00Z"), "optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"), "lastHeartbeat" : ISODate("2018-06-14T07:07:11.336Z"), "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"), "pingMs" : NumberLong(0), "configVersion" : -2

Further investigation using the db.runCommand({getLog:"rs"} reveals the following:

"2018-06-14T12:23:54.223+0800 I REPL [replexec-5] Member Machine 2 is now in state RS_DOWN"

Why is my machine on STARTUP when I first add it? What is this RS_DOWN? I'm using MONGO 3.64 for both machines. I always delete local db before trying out the scripts

  • There are a number of reasons why the server instance might have gone down; the answer can probably be found in the server log. MongoDB is generally pretty good at writing important information to its log, such as the shutdown process. Commented Jun 14, 2018 at 12:36
  • I read through the Machine 2 logs and found nothing to be suspicious. connection accepted from Machine 1. After that, end connection Machine 1. Between them, there is received client metadata from Machine 1. It is actually still running, just forever in startup mode
    – Lumo Woong
    Commented Jun 18, 2018 at 7:40
  • Running rs.status() on Machine 2 gives this rs.status() { "info" : "run rs.initiate(...) if not yet done for the set", "ok" : 0, "errmsg" : "no replset config has been received", "code" : 94, "codeName" : "NotYetInitialized" }
    – Lumo Woong
    Commented Jun 18, 2018 at 7:41
  • I found a similar problem: stackoverflow.com/questions/30297133/…
    – Lumo Woong
    Commented Jun 18, 2018 at 7:45

1 Answer 1


I figured out what is wrong with my replica set clusters. You need to provide an argument to rs.initiate(), which is the configuration document. If you don't specify the document, it will read the configuration from the /etc/mongod.conf which will has no configuration whatsoever for the replica set. The configuration for rs.initiate() looks something like this:

rs.initiate( { _id: "myReplSet", version: 1, members: [ { _id: 0, host : "mongodb0.example.net:27017" }, { _id: 1, host : "mongodb1.example.net:27017" }, { _id: 2, host : "mongodb2.example.net:27017" } ] } )

But if you do not know before hand how many replica sets you want to add to the cluster it is ok, just specify the first one and the subsequent ones will be added without any problems:

rs.initiate( { _id: "myReplSet", version: 1, members: [ { _id: 0, host : "mongodb0.example.net:27017" } ] } )

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.