gpt4 book ai didi

node.js - 错误 : failed to connect to [localhost:27017] when running MEAN app on HEROKU

转载 作者:可可西里 更新时间:2023-11-01 10:04:41 24 4
gpt4 key购买 nike

我正在写我的第二个 MEAN应用程序。第一个是手动构建聚合组件(我不知道 MEAN )并将其托管在 HEROKU;我试图使用 MONGOOSE但由于在 HEROKU 连接数据库时出现问题而放弃了——它在我的 MAC 上运行良好。这一次它可以在我的 MAC 上运行,但我仍然遇到连接问题;我不想抛弃 MONGOOSE。在这一点上,我所拥有的只是基于其 zip 文件构建的 vanilla MEAN 应用程序,该 zip 文件是从 MEAN GitHUB repository 下载的。 .请参阅下面我从 HEROKU 获得的日志:

2013-09-10T01:33:28.045816+00:00 heroku[web.1]: Starting process with command `grunt`
2013-09-10T01:33:29.526090+00:00 app[web.1]: Running "jshint:all" (jshint) task
2013-09-10T01:33:29.567534+00:00 app[web.1]: >> 1 file lint free.
2013-09-10T01:33:29.568809+00:00 app[web.1]:
2013-09-10T01:33:29.568809+00:00 app[web.1]: Running "compass:dist" (compass) task
2013-09-10T01:33:29.573055+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574527+00:00 app[web.1]: Warning: Cannot read property 'stdout' of undefined Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]:
2013-09-10T01:33:29.575774+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]: Running "compass:dev" (compass) task
2013-09-10T01:33:29.576128+00:00 app[web.1]: Running "concurrent:target" (concurrent) task
2013-09-10T01:33:29.576043+00:00 app[web.1]:
2013-09-10T01:33:30.414023+00:00 app[web.1]: Running "nodemon:dev" (nodemon) task
2013-09-10T01:33:30.511082+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] v0.7.10
2013-09-10T01:33:30.511537+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] to restart at any time, enter `rs`
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/config
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/app
2013-09-10T01:33:30.536018+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] Unable to write to temp directory. If you experience problems with file reloading, ensure /tmp is writable.
2013-09-10T01:33:30.550590+00:00 app[web.1]: debugger listening on port 5858
2013-09-10T01:33:30.578354+00:00 app[web.1]: Running "watch" task
2013-09-10T01:33:30.624330+00:00 app[web.1]: Waiting...10 Sep 01:33:30 - [nodemon] reading ignore list
2013-09-10T01:33:31.152639+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-09-10T01:33:31.154862+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-09-10T01:33:31.148967+00:00 app[web.1]: Express app started on port 3000
2013-09-10T01:33:31.152143+00:00 app[web.1]:
2013-09-10T01:33:31.152401+00:00 app[web.1]: events.js:72
2013-09-10T01:33:31.154862+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-09-10T01:33:31.154862+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at process._tickCallback (node.js:415:13)

非常欢迎任何意见或建议。提前致谢。

最佳答案

您需要在某个地方托管 MongoDB。有许多 MongoDB 托管服务,MongoHQ 和 MongoLab 最受欢迎。我使用 MongoHQ 取得了不错的效果,但我必须承认我没有对我的系统施加压力。您可以注册免费试用(我认为您可以获得 512MB),完成后,将您的连接字符串替换为(您将在注册时获得所有详细信息):

'mongodb://username:password@domain:port/dbName'

关于node.js - 错误 : failed to connect to [localhost:27017] when running MEAN app on HEROKU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18710102/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com