I am using mongodb on ubuntu 14.04 and I ran a command to add a user to a database and set readWrite permissions to it by the following command -
mongo
and then use utthan-dev
and then do
db.createUser(
{
user: "hladdha",
pwd: "Hladdha@31",
roles: [
{ role: "readWrite", db: "utthaan-dev" }
]
}
)
Now, I am connecting in my express app by the following connection string -
mongoose.connect('mongodb://hladdha:Hladdha@Demo@localhost/utthaan-dev');
mongoose.connection.on('error', function(err) {
console.error('MongoDB connection error: ' + err);
process.exit(-1);
}
);
And now I am getting the following error in node console -
MongoDB connection error: MongoError: getaddrinfo ENOTFOUND
How should I connect the mongoose to mongodb correctly no ?