Ubuntu无法使用node来运行mongod数据库

时间:2016-09-21 15:46:39

标签: mongodb amazon-web-services ubuntu

ubuntu@ip-172-31-45-35:~/cse303.p2$ node qloader.js 

events.js:72
        throw er; // Unhandled 'error' event
          ^
Error: failed to connect to [52.33.215.205:27017]
    at null.<anonymous>     (/home/ubuntu/cse303.p2/node_modules/mongoose/node_modules/mongodb/lib/mong    odb/connection/server.js:556:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (/home/ubuntu/cse303.p2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (/home/ubuntu/cse303.p2/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:415:13)

上面是我尝试执行'node'来运行我的数据库时收到的错误消息。

我已将所有安全组设置为“所有流量”,我认为这对我的安全组来说不是问题。

当我ping它可以连接的IP地址时,这就是显示的内容。

ubuntu@ip-172-31-45-35:~/cse303.p2$ ping 52.33.215.205
PING 52.33.215.205 (52.33.215.205) 56(84) bytes of data.
64 bytes from 52.33.215.205: icmp_seq=1 ttl=63 time=1.37 ms
64 bytes from 52.33.215.205: icmp_seq=2 ttl=63 time=1.27 ms
64 bytes from 52.33.215.205: icmp_seq=3 ttl=63 time=1.21 ms
64 bytes from 52.33.215.205: icmp_seq=4 ttl=63 time=1.25 ms
^C
--- 52.33.215.205 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.218/1.281/1.376/0.072 ms

因此它可以连接到该地址,但是当我添加该端口27017时,它不起作用。

ubuntu@ip-172-31-45-35:~/cse303.p2$ ping 52.33.215.205:27017
ping: unknown host 52.33.215.205:27017

我不确定我的mongod是否正常运行,这就是我得到的。

ubuntu@ip-172-31-22-135:~$ sudo service mongodb start
mongodb start/running, process 1382

1 个答案:

答案 0 :(得分:2)

您无法ping通端口。 Ping是ICMP而不是TCP或UDP。行mongodb start/running, process 1382表示MongoDB正在运行。

MongoDB的绑定IP可能设置为127.0.0.1。在MongoDB配置中,检查bind_ip的值。它可能设置为localhost(127.0.0.1),因此只接受来自本地VM的连接。

有许多指南可以提供帮助,例如thisthis