Though I can connect to my Mongodb Atlas Cluster
, from my express app
on a local machine through the following connection string, but cannot connect when the same app is running on an EC2
.
mongodb+srv://<<username>>:<password>@cluster0.xxxx.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
Have set both inbound and outbound rules on EC2
as "allowed from anywhere" for ssh/http/https/allTCP on both ipv4/ipv6
Resolved. While transferring my app files from local machine to EC2, the.env file did not get transferred. I had used scp -r... to transfer the app folder.
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.