App server not being able to connect to mongodb anymore



Hi everyone! Anyone familiar w cloud9 that could pls help me ?
I was developing a fullstack app for learning purposes
using a node js server w express and for a DB mongodb and mongoose.

Can someone please explain/interpret the errors,
I tested the app a few months back and it worked fine; just recently
starting getting these:

the 1st error is what I get when starting my server app file:

$ node app.js


   process.nextTick(function() { throw err; })

MongoError: failed to connect to server [localhost:27017] on first connect

at null. (/home/ubuntu/workspace/9_RESTfulBlogApp/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:325:35)

at emitOne (events.js:77:13)
at emit (events.js:169:7)

at null. (/home/ubuntu/workspace/9_RESTfulBlogApp/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:270:12)

at g (events.js:260:16)
at emitTwo (events.js:87:13)
at emit (events.js:172:7)
at Socket.

at Socket.g (events.js:260:16)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)

at emitErrorNT (net.js:1269:8)
at nextTickCallbackWith2Args (node.js:442:9)

at process._tickCallback (node.js:356:17)

and this is what I get when trying to go into my db:

~ $ ./mongod
2017-06-06T04:58:56.066+0000 ** WARNING: --rest is specified without --httpinterface,

2017-06-06T04:58:56.066+0000 ** enabling http interface

warning: bind_ip of is unnecessary; listens on all ips by default

2017-06-06T04:58:56.069+0000 [initandlisten] MongoDB starting : pid=2630 port=27017 dbpath=data 64-bit host=rsol72-rsol72-4117153

2017-06-06T04:58:56.069+0000 [initandlisten] db version v2.6.12

2017-06-06T04:58:56.069+0000 [initandlisten] git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a

2017-06-06T04:58:56.069+0000 [initandlisten] build info: Linux 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49

2017-06-06T04:58:56.069+0000 [initandlisten] allocator: tcmalloc

2017-06-06T04:58:56.069+0000 [initandlisten] options: { net: { bindIp: “”, http: { RESTInterfaceEnabled:
true, enabled: true } }, storage: { dbPath: “data”, journal: { enabled: false } } }

2017-06-06T04:58:56.106+0000 [initandlisten] waiting for connections on port 27017

2017-06-06T04:58:56.107+0000 [websvr] admin web console waiting for connections on port 28017

2017-06-06T04:59:56.087+0000 [clientcursormon] mem (MB) res:155 virt:719

2017-06-06T04:59:56.087+0000 [clientcursormon] mapped:560

2017-06-06T04:59:56.087+0000 [clientcursormon] connections:0
and for trying to access the mongo shell I get this:
$ mongo
MongoDB shell version: 2.6.12
connecting to: test
2017-07-21T04:36:28.302+0000 warning: Failed to connect to,
reason: errno:111 Connection refused
Error: couldn’t connect to server (,
connection attempt failed at src/mongo/shell/mongo.js:146

exception: connect failed

I also did create another workspace that uses MySql, prior to coming across
the errors not sure that’d be the reason or a factor.

I tried a couple solutions out there like going to the data folder where cloud 9 stores the data for mongo
and deleting mongod.lock* if there,
also tried by repairing the db, but none of that has worked.


Just to make sure, check that you are running ./mongod in one terminal tab, then opening another one (Alt+T) and trying to either run your app or connect using the Mongo CLI in that new tab. If that’s not the problem, are the contents of the ./mongod file the same as the ones described here:

And if they are the same and you’re still having trouble, you might try updating your MongoDB and trying again, though that probably won’t make any difference.


Thank you dannytech !!