Connect to a replicaset


i installed a two node replica on two linux server (ubuntu 20.x).

and connect from my nodejs application mit the specified connection string and specify all two nodes in connectionstring.

Now, to test whether a failure works and the database can still be reached, I switch off a node.

and now my connection runs in a timeout.

rs.status () also shows that a node cannot be reached. and a node can be reached. However, I get a connection timeout.

after swtich on the “failed” node every thing works fine again and my connection is there, without any problems.

What i am doing wrong?

any suggestion?
thank you.

This is not a valid configuration/setup.Minimum 3 nodes are needed
You need majority voting members up to elect a new primary
Check this link

Setup a 2 node mongodb replica set


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.