Reputation: 767
I can't connect to my mongo instance running on the free tier AWS Amazon Linux 2 AMI. I've followed several pages online and I can confirm what I've done, yet I'm not able to connect to mongo remotely.
Is there anything else I can try? Thanks
SSH command
ssh -i my-key.pem [email protected]
changed mongo binding setting
bindIp: 0.0.0.0
Restart mongo
sudo service mongod restart
Update - inbound rules
Error received when trying to connect to mongo from local machine
Terminal command $ mongo 1.1.1.1
[js] Error: couldn't connect to server 1.1.1.1:27017, connection attempt failed: SocketException: Error connecting to 1.1.1.1:27017 :: caused by :: Operation timed out :
Mongo configuration file (from EC2 machine)
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
security:
authorization: 'enabled'
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
~
Upvotes: 4
Views: 3292
Reputation: 1549
Don't comment the bindIp settings. If you comment the bindIp setting it will default to localhost. You won't be able to connect from outside network. Enable bindIp settings and set the value to 0.0.0.0.
Also, check your inbound rule IP range and port(27017).
Update the inbound rule to accept ipv4 addresses (0.0.0.0/0)
Upvotes: 6