I have a simple NodeJS project which is supposed to connect to a MongoDB server:
const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const bodyParser = require('body-parser');
const db = require('./config/db');
const app = express();
const port = 8030;
app.use(bodyParser.urlencoded({ extended: true }));
console.log(db.url)
MongoClient.connect(db.url, (err, database) => {
if(err) return console.log(err)
require('./app/routes')(app, database);
app.listen(port, () => {
console.log('Server is listenning on port 8030....');
});
});
variable db.url
contains mongodb://test:test@ds147421.mlab.com:47421/testnode
where test
is a database user username and test
is his password.
I have this error thrown:
{ [MongoError: failed to connect to server [ds062919.mlab.com:62919] on first connect [MongoError: connection 0 to ds062919.mlab.com:62919 timed out]]
name: 'MongoError',
message: 'failed to connect to server [ds062919.mlab.com:62919] on first connect [MongoError: connection 0 to ds062919.mlab.com:62919 timed out]' }
I don't know what I've done wrong here.
Any idea ?
via Baptiste Arnaud
No comments:
Post a Comment