RhumB
RhumB

Reputation: 141

Ubuntu can't use node to run mongod database

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)

above is the error message i got when trying to do 'node' to run my database.

I have set all my security group to 'all traffic', I suppose it's not a problem with my security group.

When I ping that ip address it can connect, this is what is shows.

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

So it can connect to that address, but when i add that port 27017, it does't work.

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

I am not sure whether my mongod is running properly, this is what i got.

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

Upvotes: 0

Views: 43

Answers (1)

jzonthemtn
jzonthemtn

Reputation: 3404

You can't ping a port. Ping is ICMP and not TCP or UDP. The line mongodb start/running, process 1382 indicates that MongoDB is running.

It is likely that MongoDB's bind IP is set to 127.0.0.1. In the MongoDB configuration, check the value of bind_ip. It is likely set to localhost (127.0.0.1) and thus will only accept connections from the local VM.

There are many guides out there that can help, such as this or this.

Upvotes: 2

Related Questions