1

So I installed mongoDB and installed mongoose properly from the terminal on the IDE Cloud 9. But when I run this code

var express = require('express');
var bodyparser = require('body-parser');
var mongoose = require('mongoose');
var configDB = require('./database.js');


var mongoURI = 'mongodb://' + process.env.IP;
//Prints out "mongodb://0.0.0.0"
console.log(mongoURI);
mongoose.connect(mongoURI);

It ends up getting this error:

events.js:163
  throw er; // Unhandled 'error' event
  ^
MongoError: failed to connect to server [0.0.0.0:27017] on first connect 
[MongoError: connect ECONNREFUSED 0.0.0.0:27017]

And I couldn't find a solution for people using C9 so I was wondering what I need to do to fix this problem. Thank you.

Michael Gee
  • 252
  • 1
  • 4
  • 16
  • Somehow I do not think you actually [Installed MongoDB server](https://docs.mongodb.com/manual/installation/) on your Cloud9 VM. Whilst you possibly can, I don't think even the space requirements would be enough without using a "paid" instance. You probably want an external provider, where the actual MongoDB instance is on another server anyway. There a "free" ( as in beer ) services available for that, with limited use restrictions of course. – Neil Lunn Jul 05 '17 at 23:50
  • So I'm guessing I would need to use mlab.com? – Michael Gee Jul 05 '17 at 23:53
  • Well I'm not going to recommend anyone's particular product, but that is one of the available options yes. – Neil Lunn Jul 05 '17 at 23:53
  • Thanks it worked – Michael Gee Jul 06 '17 at 02:08

0 Answers0