Cannot connect to MongoDB on AWS (errno:111 Connection refused)

Question:

I have followed AWS’ instructions (link) for installing MongoDB on AWS, and things seem to work until I try to connect to it.

When I run mongo, I get this connection error:

And that happens even if I comment out the bind_ip setting in the mongod.conf file (a common suggestion on forums), or set it to 0.0.0.0. Mongo did install, as I can run mongo --nodb successfully. Can someone suggest help with my connection problem?

Thanks in advance!

EDIT: Whoops, my script had not the permissions needed to start the mongo daemon, so I started it manually with sudo service mongod start, and now it works! Thanks!

Answer:

“mongo –nodb” will start a “dummy mongod service” and connect you directly into to it.

“mongo” will try to find a mongod service on port 27017 (standard port) on 127.0.0.1 (standard host). Equals: mongo –host 127.0.0.1 –port 27017

To check if your mongod service has started on your server:

Start your mongod service:

If still not working, check your logfile:

Leave a Reply