Reputation: 23
I'm developing a sample node.js application and it runs fine locally with
node index.js
but, when I push it to a Heroku instance, it crashes with the following errors:
2017-10-23T06:08:07.000000+00:00 app[api]: Build succeeded
2017-10-23T06:08:16.591817+00:00 heroku[web.1]: Starting process with commandnode --debug=5858 index.js
2017-10-23T06:08:17.873171+00:00 app[web.1]: Debugger listening on [::]:5858
2017-10-23T06:08:18.051769+00:00 app[web.1]: Server listening on port 8080
2017-10-23T06:09:16.966905+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-10-23T06:09:16.966905+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-10-23T06:09:17.062360+00:00 heroku[web.1]: Process exited with status 137
2017-10-23T06:09:17.107893+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-23T06:09:20.068453+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/contact" host=obscure-meadow-84857.herokuapp.com request_id=69c587a7-ba7f-49d3-8057-4b56338b2d01 fwd="49.35.12.63" dyno= connect= service= status=503 bytes= protocol=https
2017-10-23T06:09:20.137463+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-meadow-84857.herokuapp.com request_id=44f48e7a-94aa-4c10-9578-e8f50f8aeec5 fwd="49.35.12.63" dyno= connect= service= status=503 bytes= protocol=https
My package.json file is set up as follows:
{
"name": "testapp",
"version": "1.0.0",
"description": "A little test application",
"main": "basicRouting.js",
"dependencies": {
"ejs": "^2.5.7",
"express": "^4.16.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [
"tutorial"
],
"author": "Debaditya Dey",
"license": "ISC"
}
Can anyone please help me out regarding this?
Upvotes: 2
Views: 1658
Reputation: 269
In your index.js file, Define your port like this
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log("Server listening on port " + port);
});
Upvotes: 2
Reputation: 7237
2017-10-23T06:09:16.966905+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Please use process.env.PORT
for your app instead of using your own.
Upvotes: 4