节点错误:尝试访问路由/设置时连接ETIMEDOUT

我正在使用NodeJs和JSON Web令牌进行身份validation。

我创build了我的server.jsconfig.js用户模型

我的应用程序运行良好localhost:3333 (我的8080从来没有工作) 。 然后我添加了/setuppath来创build一个用户。

去/安装应用程序看起来像挂了一段时间,然后它抛出这个错误:

在这里输入图像说明

我的完整的server.js文件

 // require packages // =================================================================== var express = require('express'); var app = express(); var bodyParser = require('body-parser'); var morgan = require('morgan'); var mongoose = require('mongoose'); var jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens var config = require('./config'); // get our config file var User = require('./models/user'); // get our mongoose model // configuration // =================================================================== var port = process.env.PORT || 3333; // used to create, sign, and verify tokens mongoose.connect(config.database); // connect to database app.set('superSecret', config.secret); // secret variable // use body parser so we can get info from POST and/or URL parameters app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); // use morgan to log requests to the console app.use(morgan('dev')); // routes // =================================================================== // basic route app.get('/', function(req, res) { res.send('Hello! The API is at http://localhost:' + port + '/api'); }); app.get('/setup', function(req, res) { // create a sample user var nick = new User({ name: 'Nick Cerminara', password: 'password', admin: true }); // save the sample user nick.save(function(err) { if (err) throw err; console.log('User saved successfully'); res.json({ success: true }); }); }); // API ROUTES ------------------- // we'll get to these in a second // start the server // =================================================================== app.listen(port); console.log('Magic happens at http://localhost:' + port); 

我的完整configuration文件:

 module.exports = { 'secret' : 'ilovescotchyscotch', 'database' : 'mongodb://noder:noderauth&54;proximus.modulusmongo.net:27017/so9pojyN' }; 

看起来像数据库不可用。 你为什么要使用教程中给出的数据库? 您可以按照给定的教程注册您自己的数据库,也可以尝试在自己的机器上进行testing。