EC2 NodeJS Connected to MongoDB via Private IP

0

Full disclosure: I'm a programmer, rather than a sys admin. So I'm likely making a huge rookie error here...

I've setup 2 AWS EC2 instances. The first is running Nginx / NodeJS. The second is running MongoDB.

I can currently connect to the MongoDB server from the the NodeJS server using it's public (Elastic) IP address. But attempting the connection via it's private IP address results in the following error:

MongoNetworkError: failed to connect to server [MY PRIVATE IP ADDRESS:27017] on first connect [MongoNetworkError: connection timed out

I've opened port 27017 for both the public and private IPs on the MongoDB server. I've also enabled bindIpAll in /etc/mongod.conf to allow connections from all IP addresses.

I'm not sure what I'm missing. Could someone give me a nudge in the correct direction?

John Tiggernaught

Posted 2019-08-06T02:06:41.353

Reputation: 101

No answers