错误:连接 ETIMEDOUT 54.162.26.95:17185 [英] Error: connect ETIMEDOUT 54.162.26.95:17185

查看:71
本文介绍了错误:连接 ETIMEDOUT 54.162.26.95:17185的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从 server.js 得到响应.我的 server.js 在这里:

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:yourdbpw@ds017185.mlab.com: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');

推荐答案

mongodb 的问题.

problem with mongodb.

我可以通过 telnet ds017185.mlab.com:17185 连接到 mongodb,但似乎 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.

检查它用这个替换 mongoose.connect 行,你会得到有关问题的信息:

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

var connectionString = 'mongodb://yourdbus:yourdbpw@ds017185.mlab.com: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');
});

简而言之:如果您无法解决问题,请检查 mongodb,重新安装它或等以使其工作.

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

这篇关于错误:连接 ETIMEDOUT 54.162.26.95:17185的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆