将 MEAN 应用程序部署到 Heroku 会出现 H10 错误和 503 状态
Deploying MEAN App to Heroku Gives H10 Error & 503 Status
我正在学习 MEAN 堆栈并试图同时了解 Heroku 的工作原理。使用 this 教程,我组装了一个在我的机器上运行的工作应用程序。
当我尝试遵循 heroku 的 this tutorial and this 教程时,一切运行良好,直到我尝试 heroku open
。
在 herokuapp.com 页面显示
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
A heroku logs --tail
读取
2015-08-14T19:31:20.459454+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrouded-coast-5761.herokuapp.com request_id=e09a152f-9b52-4433-be2d-5c5a40150da7 fwd="166.170.43.70" dyno= connect= service= status=503 bytes=
已找到存储库 here。
当我 heroku local web
应用程序运行正常时。
看起来配置有问题。当我查看您的回购协议时,数据库配置引起了人们的注意。在你的 app.js 的最后一行你有 mongoose.connect('mongodb://localhost/news');
这是 heroku mongoose documentation
中的一些代码
var http = require ('http'); // For serving a basic web page.
var mongoose = require ("mongoose"); // The reason for this demo.
// Here we find an appropriate database to connect to, defaulting to
// localhost if we don't find one.
var uristring =
process.env.MONGOLAB_URI ||
process.env.MONGOHQ_URL ||
'mongodb://localhost/HelloMongoose';
// The http server will listen to an appropriate port, or default to
// port 5000.
var theport = process.env.PORT || 5000;
// Makes connection asynchronously. Mongoose will queue up database
// operations and release them when the connection is complete.
mongoose.connect(uristring, function (err, res) {
if (err) {
console.log ('ERROR connecting to: ' + uristring + '. ' + err);
} else {
console.log ('Succeeded connected to: ' + uristring);
}
});
您的应用似乎因缺少数据库连接而崩溃。
我正在学习 MEAN 堆栈并试图同时了解 Heroku 的工作原理。使用 this 教程,我组装了一个在我的机器上运行的工作应用程序。
当我尝试遵循 heroku 的 this tutorial and this 教程时,一切运行良好,直到我尝试 heroku open
。
在 herokuapp.com 页面显示
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
A heroku logs --tail
读取
2015-08-14T19:31:20.459454+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrouded-coast-5761.herokuapp.com request_id=e09a152f-9b52-4433-be2d-5c5a40150da7 fwd="166.170.43.70" dyno= connect= service= status=503 bytes=
已找到存储库 here。
当我 heroku local web
应用程序运行正常时。
看起来配置有问题。当我查看您的回购协议时,数据库配置引起了人们的注意。在你的 app.js 的最后一行你有 mongoose.connect('mongodb://localhost/news');
这是 heroku mongoose documentation
var http = require ('http'); // For serving a basic web page.
var mongoose = require ("mongoose"); // The reason for this demo.
// Here we find an appropriate database to connect to, defaulting to
// localhost if we don't find one.
var uristring =
process.env.MONGOLAB_URI ||
process.env.MONGOHQ_URL ||
'mongodb://localhost/HelloMongoose';
// The http server will listen to an appropriate port, or default to
// port 5000.
var theport = process.env.PORT || 5000;
// Makes connection asynchronously. Mongoose will queue up database
// operations and release them when the connection is complete.
mongoose.connect(uristring, function (err, res) {
if (err) {
console.log ('ERROR connecting to: ' + uristring + '. ' + err);
} else {
console.log ('Succeeded connected to: ' + uristring);
}
});
您的应用似乎因缺少数据库连接而崩溃。