我正在尝试在heroku上运行节点应用程序,我收到了这条消息:
Process exited with status 137
2015-08-21T15:19:16.278225+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-refuge-1097.herokuapp.com request_id=3d934205-ea72-44f2-9dd0-4d5aa1521d8e fwd="77.132.40.135" dyno= connect= service= status=503 bytes=
有我的server.js文件
hostname = process.env.HOSTNAME || 'localhost',
port = parseInt(process.env.PORT, 10) || 3000,
publicDir = process.argv[2] || __dirname + '/public';
app.get("/", function (req, res) {
res.redirect("/index.html");
});
app.use(methodOverride());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.static(publicDir));
app.use(errorHandler({
dumpExceptions: true,
showStack: true
}));
app.listen(port, hostname);
我的Procfile
web: node server.js
和我的package.json
{
"name": "myApp",
"version": "0.1.0",
"dependencies": {
"express": "^4.1.2",
"body-parser": "^1.1.2",
"errorhandler": "^1.0.1",
"method-override": "^1.0.0"
},
"engines": {
"node": "0.12.4",
"npm": "2.10.1"
}
}
我正在试图找出问题的来源,但我没有任何想法。
答案 0 :(得分:1)
这是根本问题:Web process failed to bind to $PORT within 60 seconds of launch 2015-08-21T17:07:55.260958+00:00 heroku[web.1]
您绑定到localhost
,这意味着该应用只接受环回连接。当Heroku探测它是否成功绑定到$PORT
时,它没有,因为在localhost
上无法到达它。您可以通过删除hostname
位来解决这个问题:
app.listen(port);