'How can i connect to robomongo in my windows to mongodb installed on amazon ec2 instance?

I have installed mongodb v4.4.2 in my amazon linux 2 (on aws ec2 instance) and installed robomongo in my local windows machine. Now i want to connect to my db on ec2 but i always get this error window from robomongo:

Cannot connect to the MongoDB at <ec2_ipv4>:27017.

Error: Network is unreachable. Reason: couldn't connect to server <ec2_ipv4>:27017, connection attempt failed: NetworkTimeout: Error connecting to <ec2_ipv4>:27017 :: caused by :: Socket operation timed out

These are the things that i have done:

  1. Changed bindIp field in /etc/mongod.conf(in ec2 linux) file to 0.0.0.0 and port already set to 27017
  2. stopped and started the mongod server again.
  3. Exposed the port 27017 in security groups in my aws account with tcp protocol with source set to 0.0.0.0/0
  4. in robomongo created a new connection with address: "ipv4 address of ec2 instance" and port = 27017

Is there anything that i have missed. Why is my connection not being established?



Solution 1:[1]

I fixed this by add EC2's private IPv4 as a bind IP in /etc/mongod.conf

so it would look like this

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1,<your-ec2-private-ipv4>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Heri Hakim Setiawan