mongo - couldn't connect to server 127.0.0.1:27017

Tampa picture Tampa · Nov 9, 2012 · Viewed 424.9k times · Source

I am coming from riak and redis where I never had an issue with this services starting, or to interact.

This is a pervasive problem with mongo and am rather clueless. Restarting does not help.I am new to mongo.

mongo
MongoDB shell version: 2.2.1
connecting to: test
Fri Nov  9 16:44:06 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

This is what I see in the logs.

 now open)
Fri Nov  9 16:44:34 [conn47] end connection 10.29.16.208:5306 (1 connection now open)
Fri Nov  9 16:45:04 [initandlisten] connection accepted from 10.29.16.208:5307 #48 (2 connections now open)
Fri Nov  9 16:45:04 [conn48] end connection 10.29.16.208:5307 (1 connection now open)
Fri Nov  9 16:45:04 [initandlisten] connection accepted from 10.29.16.208:5308 #49 (2 connections now open)
Fri Nov  9 16:45:04 [conn49] end connection 10.29.16.208:5308 (1 connection now open)
Fri Nov  9 16:45:34 [initandlisten] connection accepted from 10.29.16.208:5316 #50 (2 connections now open)
Fri Nov  9 16:45:34 [conn50] end connection 10.29.16.208:5316 (1 connection now open)
Fri Nov  9 16:45:34 [initandlisten] connection accepted from 10.29.16.208:5317 #51 (2 connections now open)
Fri Nov  9 16:45:34 [conn51] end connection 10.29.16.208:5317 (1 connection now open)
Fri Nov  9 16:46:04 [initandlisten] connection accepted from 10.29.16.208:5320 #52 (2 connections now open)
Fri Nov  9 16:46:04 [conn52] end connection 10.29.16.208:5320 (1 connection now open)
Fri Nov  9 16:46:04 [initandlisten] connection accepted from 10.29.16.208:5321 #53 (2 connections now open)
Fri Nov  9 16:46:04 [conn53] end connection 10.29.16.208:5321 (1 conn

Answer

Ravi Hamsa picture Ravi Hamsa · Jun 12, 2013

Normally this caused because you didn't start mongod process before you try starting mongo shell.

Start mongod server

mongod

Open another terminal window

Start mongo shell

mongo