I have to face this problem when I tried to run two mongod instances on the same machine. It throws an error when I provide both
rs.add("localhost:27027") (or) rs.add("127.0.0.1:27027")
where 27027 is the port number of the secondary.
Decision:
Pass hostname instead of ip address
rs.add("myhostname:27027")
Fizer khan
source share