简体   繁体   中英

AWS elastic beanstalk Node.js app is not connecting to Mongodb atlas

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM