Unable to connect to database: ReplicaSetNoPrimary Error

I received the above error after trying to connect to my mongo cluster via nodejs.

Here is my uri string with credentials omitted:

I also tested this when whitelisting all IP addresses and still getting the error. What am i doing wrong here?


were you able to find any solution

@Stennie_X can you please help on this issue?

@Stennie_X @Piti.Champeethong can you help on this… i’m working on mongoose with lambda function it would work first time but after sometime would get this error?

Welcome to the MongoDB Community @santhosh_h1 !

Please share more details about your environment:

  • version of Mongoose
  • version of MongoDB Node.js driver
  • description of how your issue manifests

You may find this tutorial a helpful reference: Write A Serverless Function with AWS Lambda and MongoDB | MongoDB

If your Lambda function works for a while and eventually runs into a connection error, I think this suggests you may have cached a stale connection and perhaps need some retry logic.


1 Like

sorry for the delayed response

1 Like

Hey @santhosh_h1 did you find a solution? Facing same issue since a couple of days!

I have not got any solution

1 Like

hey there? any solution?