Error using rs.add

I get this error message while attempting to add members to the cluster:
“errmsg” : “Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2”,

Please show us rs.add() command you used
Did you use IP or hostname?

I used rs.add(“m103:27002”)

This may not work.m103 is specific to Vagrant
How did you setup your replica?
I think you have to use localhost

dbPath: /var/mongodb/db/2
bindIp: localhost
port: 27002
authorization: enabled
keyFile: /var/mongodb/pki/m103-keyfile
destination: file
path: /var/mongodb/logs/mongod2.log
logAppend: true
fork: true
replSetName: m103-repl

Try this


Solved! Thank you…would you be willing to add a quick “why it worked”?

As i mentioned before m103 works only in Vagrant env(old version of course)
In new format of course we are using only localhost for bindip
The bindIp param can have values like below
bindIp: localhost,IP—>where IP is ip of hostname
Since IP is not used it will not recognise/resolve m103
Hope it clarifies

1 Like

Hi @Steve_33394,

Let us know if you still have any doubt.

~ Shubham

Hello @Ramachandra_Tummala i tried using your way, but still facing error
user@M103# rs.add(“localhost:27003”)
bash: syntax error near unexpected token `“localhost:27003”’

Hello @James_Ng ,

You are missing one crucial step which I guess is

  1. Reconnect to your primary node as m103-admin and add the other two nodes to your replica set using rs.add()

Otherwise your command is right. Thanks

1 Like

Hello there, i have reconnected to the main m103 admin node, as the test that didnt pass is the remaining nodes, the second and third.

Do not worry @James_Ng . Try again and again carefully because you got ∞ Unlimited Attempts. Take your time, find the mistake you are doing and carry on.

2 posts were split to a new topic: Error adding rs.add()