MongoDB

Fix MongoDB errno:61 Connection refused on OSX

I have just installed MongoDB thru homebrew, but I got this error when trying to open mongodb shell after the installation. Below is the error stracktrace.

MongoDB shell version: 3.2.6
connecting to: test
2016-05-29T22:57:35.930+0700 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2016-05-29T22:57:35.931+0700 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

This error caused by the mongodb service not yet started. I fixed this by starting the service following this command.

$ brew services start mongodb

Reference: http://stackoverflow.com/a/23465286/1936697