MongoDB on an AWS instance, reason: errno:61 Connection refused

From the netstat output: tcp 0 0 localhost:27017 : LISTEN 2025/mongod - Looks like it is accepting connections only from localhost(samehost) - You have to make it run on 0.0.0.0 or the Public IP.


Check in /etc/mongod.conf

# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip=127.0.0.1

Comment that line and reload the service. It should work.


I modified in /etc/mongod.conf

# network interfaces
    net:
      port: 27017
#  bindIp: 127.0.0.1  
      bindIp: 0.0.0.0`

Then,

sudo service mongod restart


sudo netstat -utpl | grep mongo

And check if: 0.0.0.0:27017 appear,