I'm having trouble connecting MongoDB.
Follow the code:
var express= require('express');
var app= express();
var bodyParser= require('body-parser');
var db_string= 'mongodb://localhost/teste'
var mongoose= require('mongoose');
var db= mongoose.connection;
mongoose.connect(db_string);
db.on('error', console.error.bind(console, 'Erro ao conectar no banco'));
db.once('open', function(){
var testeSchema= mongoose.Schema({
name: String,
});
});
Error displayed on console:
Erro ao conectar no banco { [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' }