“message”:“Server selection timed out after 30000 ms”,“reason”:{“type”:“ReplicaSetNoPrimary”,“servers”:{},“stale”:false,“compatible”:true,“heartbeatFrequencyMS”:10000,“localThresholdMS”:15,“setName”:“atlas-uhi03q-shard-0”}
This is error I am receiving when I connect to mongo atlas instance from ECS tasks (EC2 instance running on private subnet). Runs well when I run this application from localhost. I have also enabled VPC peering and IP under network access is open to the world. Cannot figure out the issue. Appreciate some help here.
Runs well when I run this application from localhost. I have also enabled VPC peering and IP under network access is open to the world.
Do you mean your Atlas instance is open to 0.0.0.0 in the network access tab from Atlas? If yes, then it sounds like it’s a network connectivity issues from the AWS setup instead of something that was Atlas-specific. In my experience, this is typically caused by misconfigured AWS security policies, but there could be other reasons as well.
Having said that, the Server selection timed out message is consistent with the app unable to connect to the server.