we have an EC2 MongoDB 2.4 instance from Amazon MarketPlace.
when i try to access it from my computer using the mongo command like so:
mongo xx-xx-xx-xx-xx.compute-1.amazonaws.com
i get the following error
Error: couldn't connect to server xx-xx-xx-xx-xx.compute-1.amazonaws.com:27017 at src/mongo/shell/mongo.js:147
exception: connect failed
- i can connect to the remote instance using ssh so it is reachable.
- the port is the default port 27017.
- mongod is running and working on the remote instance.
any suggestions on how to fix this?
Best Answer
As frisky said, you have to open the port 27017 at the EC2 Security Group Console. (To know more about how to do that: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html)
But you also need to change the
bind_ip
variable at the /etc/mongodb.conf file. You need to comment the line or assign the ip that will be able to connect the DB to it.