Heroku “Process exited with status 137” node.js ap

2020-07-03 07:30发布

问题:

I recently posted a question on a similar topic. I did a major overhaul of everything on the URL, and the same thing happened as last time: I could deploy everything and run it using heroku local web. When I went to the web dyno, it said I had an application error and I then check the logs. Here is what it said (I am using a project on github called atwork):

2017-05-02T02:35:39.191493+00:00 app[web.1]: Loaded model: chats.js
2017-05-02T02:35:39.200517+00:00 app[web.1]: Loaded model: streams.js
2017-05-02T02:35:39.196830+00:00 app[web.1]: Loaded model: posts.js
2017-05-02T02:35:39.209761+00:00 app[web.1]: Loaded model: users.js
2017-05-02T02:35:40.067321+00:00 app[web.1]: AtWork running at http://:::8111
2017-05-02T02:35:50.116492+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=44a6e779-e6b8-4a33-a5b9-53430af2ad8f fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https
2017-05-02T02:36:35.859814+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-05-02T02:36:35.859903+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-05-02T02:36:35.956564+00:00 heroku[web.1]: Process exited with status 137
2017-05-02T02:36:35.969766+00:00 heroku[web.1]: State changed from starting to crashed
2017-05-02T02:37:22.933285+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=80ffc71f-d792-4538-b50a-5140b7658819 fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https

I am a beginner to Heroku and Node.js, so any help is appreciated. I will provide any information needed to find an answer.

回答1:

I checked the logs, it said that at=error code=H10 desc="App crashed", it means you have uncaught Exception, so you should check your code.

if you want to use mongodb on Heroku, you should try to add the mongodb addon for your application. you can find the doc here

and try to use process.env.PORT, not the port you want to use.

if it doesn't still solve your problem, you can try to use this command heroku run bash, this command can make you into heroku environment and start your server.



回答2:

I was getting the same error upon hosting a Node app on heroku turn out it was the port problem so just do this set the port equal to this

var port = process.env.PORT || 8080;

So process.env.PORT || 8080 means: whatever is in the environment variable PORT, or 8080 if there's nothing there.

And then set the set port variable in the following

var server=app.listen(port,function() {
console.log("app running on port 8080"); });


回答3:

It looks like your app is timing out before it actually starts the server:

App boot timeout

Could the process be taking too long to minify production assets?



回答4:

This is definitely a port issue. Just use something like this:

var port = process.env.PORT || 3002

to specify your port.

That's all.