Pio
Pio

Reputation: 4064

Can't connect to Mongodb running on EC2

I cannot connect remotely to a mongo server running on EC2, even though if I ssh into the server the mongo is running properly. Also note, that the 27017 port is open on both tcp and udp protocols. I am getting the following error:

MongoDB shell version: 2.4.8
connecting to: ec2-x...x-compute.amazonaws.com:27017/test
Thu Sep  4 13:26:04.293 Error: couldn't connect to server to: ec2-x...x-compute.amazonaws.com:27017/test at src/mongo/shell/mongo.js:147
exception: connect failed

I have Mongodb version 2.4.8 on my local host and on the server Mongodb version 2.6.4. Could the version difference be a problem?

Upvotes: 12

Views: 14763

Answers (1)

Daniel Scott
Daniel Scott

Reputation: 7903

Are you binding to the external IP? Or just localhost:

http://docs.mongodb.org/manual/reference/configuration-options/

net:
  bindIp: 127.0.0.1 # Should be 0.0.0.0 to listen on all interfaces
  port: 27017

Also, I know you said that the port is open. Did you check this using nmap/netcat? You should check the AWS security group and the local firewall to make sure it's open.

Upvotes: 37

Related Questions