title: Couldn't connect to server 127.0.0.1:27017
body: <p>I'm getting the following error:</p>
  
  <pre><code>alex@alex-K43U:/$ mongo
  MongoDB shell version: 2.2.0
  connecting to: test
  Thu Oct 11 11:46:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
  exception: connect failed
  alex@alex-K43U:/$ 
  </code></pre>
  
  <p>This is what happens when I try to start mongodb:</p>
  
  <pre><code>* Starting database mongodb                                             [fail]
  </code></pre>
  
  <p>I already tried <code>mongo --repair</code></p>
  
  <p>I made chown and chmod to <em>var, lib, and data/db and log</em> mongodb.</p>
  
  <p>Not sure what else to do. Any suggestions?</p>
  
  <p><strong>mongodb.log:</strong></p>
  
  <pre><code>***** SERVER RESTARTED *****
  
  
  Thu Oct 11 08:29:40 
  Thu Oct 11 08:29:40 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
  Thu Oct 11 08:29:40 
  Thu Oct 11 08:29:41 [initandlisten] MongoDB starting : pid=1052 port=27017 dbpath=/var/lib/mongodb 32-bit host=alex-K43U
  Thu Oct 11 08:29:41 [initandlisten] 
  Thu Oct 11 08:29:41 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
  Thu Oct 11 08:29:41 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
  Thu Oct 11 08:29:41 [initandlisten] **       with --journal, the limit is lower
  Thu Oct 11 08:29:41 [initandlisten] 
  Thu Oct 11 08:29:41 [initandlisten] db version v2.2.0, pdfile version 4.5
  Thu Oct 11 08:29:41 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
  Thu Oct 11 08:29:41 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
  Thu Oct 11 08:29:41 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
  Thu Oct 11 08:29:41 [initandlisten] Unable to check for journal files due to: boost::filesystem::basic_directory_iterator constructor: No such file or directory: "/var/lib/mongodb/journal"
  ************** 
  Unclean shutdown detected.
  Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
  *************
  Thu Oct 11 08:29:41 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
  Thu Oct 11 08:29:41 dbexit: 
  Thu Oct 11 08:29:41 [initandlisten] shutdown: going to close listening sockets...
  Thu Oct 11 08:29:41 [initandlisten] shutdown: going to flush diaglog...
  Thu Oct 11 08:29:41 [initandlisten] shutdown: going to close sockets...
  Thu Oct 11 08:29:41 [initandlisten] shutdown: waiting for fs preallocator...
  Thu Oct 11 08:29:41 [initandlisten] shutdown: closing all files...
  Thu Oct 11 08:29:41 [initandlisten] closeAllFiles() finished
  Thu Oct 11 08:29:41 dbexit: really exiting now
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I removed the lock then did mongod repair and got this error:</p>
  
  <pre><code>Thu Oct 11 12:05:37 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
  </code></pre>
  
  <p>so I did it with sudo:</p>
  
  <pre><code>alex@alex-K43U:~$ sudo mongod --repair
  Thu Oct 11 12:05:42 
  Thu Oct 11 12:05:42 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
  Thu Oct 11 12:05:42 
  Thu Oct 11 12:05:42 [initandlisten] MongoDB starting : pid=5129 port=27017 dbpath=/data/db/ 32-bit host=alex-K43U
  Thu Oct 11 12:05:42 [initandlisten] 
  Thu Oct 11 12:05:42 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
  Thu Oct 11 12:05:42 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
  Thu Oct 11 12:05:42 [initandlisten] **       with --journal, the limit is lower
  Thu Oct 11 12:05:42 [initandlisten] 
  Thu Oct 11 12:05:42 [initandlisten] db version v2.2.0, pdfile version 4.5
  Thu Oct 11 12:05:42 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
  Thu Oct 11 12:05:42 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
  Thu Oct 11 12:05:42 [initandlisten] options: { repair: true }
  Thu Oct 11 12:05:42 [initandlisten] Unable to check for journal files due to: boost::filesystem::basic_directory_iterator constructor: No such file or directory: "/data/db/journal"
  Thu Oct 11 12:05:42 [initandlisten] finished checking dbs
  Thu Oct 11 12:05:42 dbexit: 
  Thu Oct 11 12:05:42 [initandlisten] shutdown: going to close listening sockets...
  Thu Oct 11 12:05:42 [initandlisten] shutdown: going to flush diaglog...
  Thu Oct 11 12:05:42 [initandlisten] shutdown: going to close sockets...
  Thu Oct 11 12:05:42 [initandlisten] shutdown: waiting for fs preallocator...
  Thu Oct 11 12:05:42 [initandlisten] shutdown: closing all files...
  Thu Oct 11 12:05:42 [initandlisten] closeAllFiles() finished
  Thu Oct 11 12:05:42 [initandlisten] shutdown: removing fs lock...
  Thu Oct 11 12:05:42 dbexit: really exiting now
  </code></pre>
  
  <p>But still having the same problem.</p>