title: Failed to connect to mongodb in ubuntu?
body: <p>I followed this tutorial: <a href="http://howtonode.org/express-mongodb" rel="nofollow">http://howtonode.org/express-mongodb</a></p>
  
  <p>Its strange, the first time I followed the tutorial everything worked.
  But now, one day after I wanted to play with the code again I coudn't start
  the server. This is what I get:</p>
  
  <blockquote>
    <p>alex@alex-System-Product-Name:~/blog2$ node app.js Express server
    listening on port 3000 in development mode</p>
    
    <p>node.js:134
            throw e; // process.nextTick error, or 'error' event on first tick
            ^ Error: failed to connect to [localhost:27017]
        at [object Object]. (/home/alex/blog2/node_modules/mongodb/lib/mongodb/connection/server.js:189:47)
        at [object Object].emit (events.js:67:17)
        at [object Object]. (/home/alex/blog2/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:110:14)
        at [object Object].emit (events.js:67:17)
        at Socket. (/home/alex/blog2/node_modules/mongodb/lib/mongodb/connection/connection.js:301:10)
        at Socket.emit (events.js:64:17)
        at Array. (net.js:836:27)
        at EventEmitter._tickCallback (node.js:126:26) alex@alex-System-Product-Name:~/blog2$</p>
  </blockquote>
  
  <p>Any suggestions to fix this problem?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I just did:</p>
  
  <pre><code>alex@alex-System-Product-Name:~/blog2$ sudo service mongodb start
  mongodb start/running, process 9847
  alex@alex-System-Product-Name:~/blog2$ sudo service mongodb status
  mongodb stop/waiting
  alex@alex-System-Product-Name:~/blog2$ 
  </code></pre>
  
  <p>Not sure if it is running.</p>
  
  <p>and this is what I get if I type <code>$ mongo</code> in the command line:</p>
  
  <pre><code>alex@alex-System-Product-Name:~/blog2$ mongo
  MongoDB shell version: 1.8.2
  Tue Nov 15 08:09:50 *** warning: spider monkey build without utf8 support.  consider rebuilding with utf8 support
  connecting to: test
  Tue Nov 15 08:09:50 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:79
  exception: connect failed
  </code></pre>