We are trying to connect DB cluster via node application and getting the following error
MongoServerSelectionError: Server selection timed out after 30000 ms
at Timeout._onTimeout (/home/ec2-user/test/node_modules/mongodb/lib/sdam/topology.js:293:38)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(1) {
Please share the connection strings you used in both cases. I suspect that they are different and that you connect directly to one instance (vs replica set) with mongosh.
Because if you have the error ReplicaSetNoPrimary you will have the same error everywhere. The replica set is in the same state whatever client you use to connect.