错误:在HEROKU上运行MEAN应用程序时无法连接到

我正在写我的第二个平均应用程序。 第一个是手工构build的组件(我没有意识到MEAN ),并在HEROKU上托pipe; 我试图使用MONGOOSE,但放弃了与HEROKU数据库连接的问题 – 它在我的MAC上运行良好。 这一次它在我的MAC上工作,但我仍然有连接问题; 我不想放弃MONGOOSE。 在这一点上,我所拥有的是从其MEAN GitHUB存储库下载的zip文件构build的vanilla MEAN应用程序。 见下面我从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) 

任何意见的build议将非常受欢迎。 提前致谢。

你需要在某个地方托pipeMongoDB。 有一些MongoDB托pipe服务,MongoHQ和MongoLab最受欢迎。 尽pipe我必须承认我没有强调我的系统,但我已经使用了MongoHQ。 您可以注册免费试用版(我认为您可以获得512MB),一旦您完成了,请将您的连接stringreplace为(您将在注册时获得所有详细信息):

'MongoDB的://用户名:密码@域名:端口/ DBNAME'