I am trying to add the second replica set to primary.

Primary =
Secondary =

    # mongod.conf

    # for documentation of all options, see:
    #   http://docs.mongodb.org/manual/reference/configuration-options/

    # Where and how to store data.
      dbPath: **mypath**\DBs
        enabled: true
    #  engine:
    #  mmapv1:
    #  wiredTiger:

    # where to write logging data.
      destination: file
      logAppend: true
      path:  **mypath**\mongod.log

    # network interfaces
      port: 27017



      replSetName: configServers


    ## Enterprise-Only Options:



But when I try I add
rs.add("") It shows as picture . result
Please help to get run replicaset. Thanks.
I run on windows and start replicaset with service .

1 Answer 1


As per the error message says, you have added the Primary node of the replica set as localhost. The rule is all nodes of the replica set should be localhost or all should be hostname/ip address.

If you run rs.status() from primary, you will see the primary replica set member as localhost. So when you try to add a secondary with rs.add("") the system will throw an error.

How to correct this?

conf = rs.conf()

update the hostname of primary member in conf variable

then run


Now add the secondary member.

  • Thank you so much. You saved me a lot. Mar 24, 2019 at 20:52

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.