I'm trying to connect my app running on AWS EC2 to mlab endpoint. I can easily connect using the same code base from my local machine to mlab endpoint. However, when I run on AWS, I get the following error.
{ name: 'MongoError', message: 'connect ECONNREFUSED' }
I have tried increasing connectionTimeMS to 30 seconds, but I still get the same error.
From EC2 instance, I can ping the DB server and netcat is also successful.
My EC2 instance is configured to receive and send all traffic on all ports from any IP address.
I think issue might be related to outgoing traffic, but do not know how to configure.
Thanks