【发布时间】:2015-11-02 00:04:46
【问题描述】:
我是 Node.js 的超级新手,所以这可能是一个非常基本的问题,但是当控制台告诉我时发生了什么
Error: unable to connect to database at mongodb://localhost/realjoet-me-development
我正在使用 swig、sass、node、express、gulp、nodemon 和 yeoman 运行我的环境。
我在 Heroku 上使用 MongoLab 插件设置了我的数据库。
什么可能导致此错误,然后导致我的应用程序崩溃,因此我无法在本地主机上查看它??
您还需要了解什么才能更好地了解我的情况?
这是整个控制台日志
➜ realjoet.me git:(master) ✗ gulp
[06:50:13] Using gulpfile ~/Sites/realjoet.me/gulpfile.js
[06:50:13] Starting 'sass'...
[06:50:13] Starting 'develop'...
[06:50:13] Finished 'develop' after 6.51 ms
[06:50:13] Starting 'watch'...
[06:50:13] Finished 'watch' after 9.09 ms
[06:50:13] [nodemon] 1.8.0
[06:50:13] [nodemon] to restart at any time, enter `rs`
[06:50:13] [nodemon] watching: *.*
[06:50:13] [nodemon] starting `node app.js`
[06:50:13] /Users/realjoet/Sites/realjoet.me/public/css/style.css reloaded.
[06:50:13] Finished 'sass' after 243 ms
[06:50:13] Starting 'default'...
[06:50:13] Finished 'default' after 4.09 μs
[06:50:14] /Users/realjoet/Sites/realjoet.me reloaded.
Express server listening on port 3000
/Users/realjoet/Sites/realjoet.me/node_modules/mongodb/lib/server.js:235
process.nextTick(function() { throw err; })
^
Error: unable to connect to database at mongodb://localhost/realjoet-me-development
at NativeConnection.<anonymous> (/Users/realjoet/Sites/realjoet.me/app.js:11:9)
at NativeConnection.emit (events.js:107:17)
at NativeConnection.Connection.error (/Users/realjoet/Sites/realjoet.me/node_modules/mongoose/lib/connection.js:425:8)
at /Users/realjoet/Sites/realjoet.me/node_modules/mongoose/lib/connection.js:452:14
at /Users/realjoet/Sites/realjoet.me/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:52:21
at /Users/realjoet/Sites/realjoet.me/node_modules/mongodb/lib/db.js:226:14
at null.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb/lib/server.js:233:9)
at g (events.js:199:16)
at emit (events.js:110:17)
at null.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb-core/lib/topologies/server.js:263:68)
at g (events.js:199:16)
at emit (events.js:110:17)
at null.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb-core/lib/connection/pool.js:77:12)
at g (events.js:199:16)
at emit (events.js:110:17)
at Socket.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb-core/lib/connection/connection.js:121:49)
[06:50:14] [nodemon] app crashed - waiting for file changes before starting...
[06:50:27] [nodemon] restarting due to changes...
[06:50:27] [nodemon] starting `node app.js`
[06:50:28] /Users/realjoet/Sites/realjoet.me reloaded.
Express server listening on port 3000
/Users/realjoet/Sites/realjoet.me/node_modules/mongodb/lib/server.js:235
process.nextTick(function() { throw err; })
^
Error: unable to connect to database at mongodb://localhost/realjoet-me-development
at NativeConnection.<anonymous> (/Users/realjoet/Sites/realjoet.me/app.js:11:9)
at NativeConnection.emit (events.js:107:17)
at NativeConnection.Connection.error (/Users/realjoet/Sites/realjoet.me/node_modules/mongoose/lib/connection.js:425:8)
at /Users/realjoet/Sites/realjoet.me/node_modules/mongoose/lib/connection.js:452:14
at /Users/realjoet/Sites/realjoet.me/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:52:21
at /Users/realjoet/Sites/realjoet.me/node_modules/mongodb/lib/db.js:226:14
at null.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb/lib/server.js:233:9)
at g (events.js:199:16)
at emit (events.js:110:17)
at null.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb-core/lib/topologies/server.js:263:68)
at g (events.js:199:16)
at emit (events.js:110:17)
at null.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb-core/lib/connection/pool.js:77:12)
at g (events.js:199:16)
at emit (events.js:110:17)
at Socket.<anonymous> (/Users/realjoet/Sites/realjoet.me/node_modules/mongodb-core/lib/connection/connection.js:121:49)
[06:50:28] [nodemon] app crashed - waiting for file changes before starting...
【问题讨论】:
-
您的互联网连接正常吗?访问是否被防火墙阻止?您尝试访问的地址是否有可访问的数据库?
-
@Jayram 前两个不知道,但我不确定最后一个......这就是我感到困惑的地方,我想。我从我的一个创建预制环境的好友那里获取了这个 Node.js 模板(在此处查看 repo:github.com/corbanb/bdw-blog),但我不确定它是如何连接的/我将如何查看第三个问题??跨度>