【发布时间】:2015-07-15 10:36:57
【问题描述】:
我在运行我的应用程序时出错。
应用程序错误。 应用程序发生错误,无法提供您的页面。请稍后再试。
如果您是应用程序所有者,请查看您的日志以了解详细信息。
Heroku 日志:
May 05 08:17:00 game app/web.1: > node app.js
May 05 08:17:04 game app/web.1: error: Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running?
May 05 08:17:04 game app/web.1: Error details:
May 05 08:17:04 game app/web.1: { [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' }
May 05 08:17:04 game app/web.1: at _createError (/app/node_modules/sails-mongo/lib/adapter.js:101:23)
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/lib/adapter.js:104:13
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/lib/connection.js:25:20
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/node_modules/mongodb/lib/mongo_client.js:236:20
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/node_modules/mongodb/lib/db.js:197:14
May 05 08:17:04 game app/web.1: at null.<anonymous> (/app/node_modules/sails-mongo/node_modules/mongodb/lib/server.js:226:9)
May 05 08:17:04 game app/web.1: at g (events.js:199:16)
May 05 08:17:04 game app/web.1: at emit (events.js:110:17)
May 05 08:17:04 game app/web.1: at null.<anonymous> (/app/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:239:68)
May 05 08:17:04 game app/web.1: at g (events.js:199:16)
May 05 08:17:04 game app/web.1: at emit (events.js:110:17)
May 05 08:17:04 game app/web.1: at null.<anonymous> (/app/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:77:12)
May 05 08:17:04 game app/web.1: at g (events.js:199:16)
May 05 08:17:04 game app/web.1: at emit (events.js:110:17)
May 05 08:17:04 game app/web.1: at Socket.<anonymous> (/app/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:118:49)
May 05 08:17:04 game app/web.1: at Socket.g (events.js:199:16) { [Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running?
May 05 08:17:04 game app/web.1: Error details:
May 05 08:17:04 game app/web.1: { [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' }]
May 05 08:17:04 game app/web.1: originalError: { [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' } }
May 05 08:17:04 game app/web.1: /app/node_modules/sails-mongo/node_modules/mongodb/lib/mongo_client.js:385
May 05 08:17:04 game app/web.1: throw err
May 05 08:17:04 game app/web.1: ^
May 05 08:17:04 game app/web.1: TypeError: Cannot set property 'connection' of undefined
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/lib/adapter.js:106:53
May 05 08:17:04 game app/web.1: npm ERR! Linux 3.13.0-49-generic
May 05 08:17:04 game app/web.1: npm ERR! code ELIFECYCLE
May 05 08:17:04 game app/web.1: npm ERR! gameMouseCat@0.0.0 start: `node app.js`
May 05 08:17:04 game app/web.1: npm ERR! Exit status 1
May 05 08:17:04 game app/web.1: npm ERR!
May 05 08:17:04 game app/web.1: npm ERR! Failed at the gameMouseCat@0.0.0 start script 'node app.js'.
May 05 08:17:04 game app/web.1: npm ERR! This is most likely a problem with the gameMouseCat package,
May 05 08:17:04 game app/web.1: npm ERR! not with npm itself.
May 05 08:17:04 game app/web.1: npm ERR! Tell the author that this fails on your system:
May 05 08:17:04 game app/web.1: npm ERR! node app.js
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/lib/connection.js:31:5
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/node_modules/mongodb/lib/mongo_client.js:382:15
May 05 08:17:04 game app/web.1: at process._tickDomainCallback (node.js:381:11)
May 05 08:17:04 game app/web.1: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
May 05 08:17:04 game app/web.1: npm ERR! node v0.12.2
May 05 08:17:04 game app/web.1: npm ERR! npm v2.7.4
May 05 08:17:04 game app/web.1: npm ERR! Please include the following file with any support request:
May 05 08:17:04 game app/web.1: npm ERR! /app/npm-debug.log
May 05 08:17:04 game app/web.1: npm ERR! You can get their info via:
May 05 08:17:04 game app/web.1: npm ERR! npm owner ls gameMouseCat
May 05 08:17:04 game app/web.1: npm ERR! There is likely additional logging output above.
May 05 08:17:05 game heroku/web.1: State changed from starting to crashed
May 05 08:17:05 game heroku/web.1: Process exited with status 1
May 05 08:19:38 game heroku/router: at=error code=H10 desc="App crashed" method=GET path="/" host=game .herokuapp.com request_id=5c4b7249-ad10-492d-acd0-efb4fbd314ed fwd="207.244.77.3" dyno= connect= service= status=503 bytes=
May 05 08:19:56 game heroku/router: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=game .herokuapp.com request_id=9678ba10-05ea-4a38-806f-12565e0ded63 fwd="207.244.77.3" dyno= connect= service= status=503 bytes=
适配器配置:
MongodbHerokuServer: {
adapter: 'sails-mongo',
url: process.env.MONGOLAB_URI
},
谁能帮帮我?我不知道该怎么做才能解决这个问题。
【问题讨论】:
-
MongoDB 在 heroku 上不是免费的,你要付费吗?如果是,您可能需要为连接设置凭据信息
-
如果你在适配器配置中看到,我放了一个 MONGOLAB 的 Env 变量。 heroku 允许您创建一个免费的实例 mongolab。 @jaumard
-
确保 MONGOLAB_URI 正确,尝试通过控制台连接
-
是
MongodbHerokuServer定义的唯一适配器吗? -
不,但是当我尝试删除生成默认 Sails 的其他适配器时,我的应用程序运行了。谢谢!!! @Meeker
标签: node.js heroku sails.js mlab sails-mongo