Siber Nietzsche
Siber Nietzsche

Reputation: 13

Error: connect ETIMEDOUT 54.162.26.95:17185

I cant get response from server.js. My server.js is here:

//dependencies

var express = require('express');

var mongoose = require('mongoose');

var bodyParser = require('body-parser');

//connect to mongodb

mongoose.connect('mongodb://yourdbus:[email protected]:17185/myfbdb');

//express

var app = express();

app.use(bodyParser.urlencoded({extended : true}));
app.use(bodyParser.json());

//routes

app.use('/api' , require('./routes/api'));

//start server

app.listen(1050);
console.log('server is running on port 1050');

Upvotes: 1

Views: 11354

Answers (1)

num8er
num8er

Reputation: 19372

problem with mongodb.

I can connect to mongodb via telnet ds017185.mlab.com:17185, but seems like mongodb's username, password or database name is not valid.

to check it replace mongoose.connect line with this, You'll get info about the problem:

var connectionString = 'mongodb://yourdbus:[email protected]:17185/myfbdb';
mongoose.connect(connectionString);

mongoose.connection.on('error', function(error) {
  console.error('Database connection error:', error);
});

mongoose.connection.once('open', function() {
  console.log('Database connected');
});

In short: if You cannot fix problem, so check mongodb, reinstall it or etc. to make it work.

Upvotes: 1

Related Questions