I am trying to connect to MongoDB atlas from elastic beanstalk using a Node.js app. on Mongo atlas, I opened the connection publicly for testing reasons (added 0.0.0.0/0 to the whitelist) and AWS security group allows all traffic. I still can connect to MongoDB atlas from my localhost but not from AWS EBS.
Asked
Active
Viewed 1,474 times
2
-
Did you get the solution ? – Santosh Shinde Feb 20 '19 at 13:18
1 Answers
1
Even I have faced the same issue and it solves by restart the aws elastic beanstalk instance.
Actually, we open do MongoClient.connect once when your app boots up and reuse the db object. It's not a singleton connection pool each .connect creates a new connection pool.
So for that purpose, we have to restart the instance and it will work but for the security purpose, we can try VPC Peering for MongoDB Atlas.
Hope this will help some one else..!!

Community
- 1
- 1

Santosh Shinde
- 6,045
- 7
- 44
- 68