无法连接到EC2上运行的Mongodb

时间:2014-09-04 10:31:39

标签: mongodb amazon-web-services amazon-ec2

我无法远程连接到在EC2上运行的mongo服务器,即使我进入服务器mongo正常运行。另请注意,27017端口在tcp和udp协议上都是打开的。我收到以下错误:

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

我的本​​地主机和服务器Mongodb version 2.4.8上有Mongodb version 2.6.4。版本差异可能是个问题吗?

1 个答案:

答案 0 :(得分:27)

您是否绑定了外部IP?或者只是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

另外,我知道你说端口是开放的。你用nmap / netcat检查了吗?您应该检查AWS安全组和本地防火墙,以确保它已打开。