title: Error in connecting to MongoDB on localhost in Mac
body: <pre><code>$ mongo
  MongoDB shell version: 2.4.5
  connecting to: test
  Mon Jul 29 19:44:07.569 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
  exception: connect failed
  </code></pre>
  
  <p>The above really shoud connect to mongo. I've already tried 'brew update' and "brew upgrade mongodb".</p>
  
  <pre><code>Brew upgrade mongodb 
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>Error: mongodb-2.4.5 already installed
  </code></pre>
  
  <p>EDIT:- running mongod &amp; gives the following error.</p>
  
  <pre><code>$ mongod &amp;
  [1] 858
  $ about to fork child process, waiting until server is ready for connections.
  forked process: 860
  all output going to: /usr/local/var/log/mongodb/mongo.log
  ERROR: child process failed, exited with error number 100
  </code></pre>
  
  <p>EDIT- 2:- The following is the mongo.log report.</p>
  
  <pre><code>***** SERVER RESTARTED *****
  
  
  Mon Jul 29 19:57:12.582 [initandlisten] MongoDB starting : pid=874 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=121.245.123.3.cdma-delhi.vsnl.net.in
  Mon Jul 29 19:57:12.582 [initandlisten] 
  Mon Jul 29 19:57:12.582 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
  Mon Jul 29 19:57:12.582 [initandlisten] db version v2.4.5
  Mon Jul 29 19:57:12.582 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
  Mon Jul 29 19:57:12.582 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
  Mon Jul 29 19:57:12.582 [initandlisten] allocator: system
  Mon Jul 29 19:57:12.582 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", fork: "true", journal: "true", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log", port: 27017, quiet: "true" }
  Mon Jul 29 19:57:12.584 [initandlisten] journal dir=/usr/local/var/mongodb/journal
  Mon Jul 29 19:57:12.584 [initandlisten] recover begin
  Mon Jul 29 19:57:12.586 [initandlisten] In File::open(), ::open for '/usr/local/var/mongodb/journal/lsn' failed with errno:13 Permission denied
  Mon Jul 29 19:57:12.586 [initandlisten]   Assertion failure f.is_open() src/mongo/db/dur_journal.cpp 567
  0x100447d8b 0x100421aec 0x10017506a 0x10017892a 0x100179961 0x100179aae 0x10016d148    0x100003657 0x100004c90 0x10000b6e1 0x1000010b4 
  0   mongod                              0x0000000100447d8b _ZN5mongo15printStackTraceERSo + 43
  1   mongod                              0x0000000100421aec _ZN5mongo12verifyFailedEPKcS1_j + 284
  2   mongod                              0x000000010017506a _ZN5mongo3dur14journalReadLSNEv + 218
  3   mongod                              0x000000010017892a _ZN5mongo3dur11RecoveryJob2goERSt6vectorIN5boost11filesystem34pathESaIS5_EE + 98
  4   mongod                              0x0000000100179961 _ZN5mongo3dur8_recoverEv + 3089
  5   mongod                              0x0000000100179aae _ZN5mongo3dur7recoverEv + 30
  6   mongod                              0x000000010016d148 _ZN5mongo3dur7startupEv + 72
  7   mongod                              0x0000000100003657 _ZN5mongo14_initAndListenEi + 1351
  8   mongod                              0x0000000100004c90 _ZN5mongo13initAndListenEi + 16
  9   mongod                              0x000000010000b6e1 main + 801
  10  mongod                              0x00000001000010b4 start + 52
  Mon Jul 29 19:57:12.592 [initandlisten] dbexception during recovery: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:567
  Mon Jul 29 19:57:12.592 [initandlisten] exception in initAndListen: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:567, terminating
  Mon Jul 29 19:57:12.592 dbexit: 
  Mon Jul 29 19:57:12.592 [initandlisten] shutdown: going to close listening sockets...
  Mon Jul 29 19:57:12.592 [initandlisten] shutdown: going to flush diaglog...
  Mon Jul 29 19:57:12.592 [initandlisten] shutdown: going to close sockets...
  Mon Jul 29 19:57:12.593 [initandlisten] shutdown: waiting for fs preallocator...
  Mon Jul 29 19:57:12.593 [initandlisten] shutdown: lock for final commit...
  Mon Jul 29 19:57:12.593 [initandlisten] shutdown: final commit...
  Mon Jul 29 19:57:12.593 [initandlisten] shutdown: closing all files...
  Mon Jul 29 19:57:12.593 [initandlisten] closeAllFiles() finished
  Mon Jul 29 19:57:12.593 [initandlisten] shutdown: removing fs lock...
  Mon Jul 29 19:57:12.593 dbexit: really exiting now
  </code></pre>