Mongo Atlas instance timeout from ECS tasks of AWS

“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.

Hi @Ajith_Nair welcome to the community!

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.

You might need to troubleshoot this by following the suggestions in How do I troubleshoot connectivity issues that I’m experiencing while using an Amazon VPC?, or posting in AWS re:Post forum for better AWS-related answers.

Best regards
Kevin

1 Like

Thanks for that, Yes Atlas instance is open to 0.0.0.0. let me check those forum for some help.