125

I deployed my app to Heroku. It's a node.js + express + socket.io app and this is the package.json file

{
  "name": "game_test",
  "author": "Ilya",
  "description": "A test app for our board game",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "dependencies": {
    "express": "3.0.6",
    "jade": "*",
    "socket.io" : "*"
  },
 "engines": {
      "node": "0.8.14"
  }
}

This is the log I get:

heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=game-test-1.herokuapp.com fwd=37.26.146.185 dyno= queue= wait= connect= service= status=503 bytes=
heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=game-test-1.herokuapp.com fwd=37.26.146.185 dyno= queue= wait= connect= service= status=503 bytes=

What does it mean?

ilyo
  • 34,891
  • 42
  • 103
  • 154
  • 6
    "App crashed" has the obvious meaning: your app crashed. Look further up in your logs to see why, or `heroku restart` to launch it again so you can watch it crash again. – willglynn Jan 14 '13 at 17:04
  • I am having the same problem. How did you fix it? – Martin Schaer Jun 08 '13 at 22:33
  • 8
    there is 1 answer to this question which has already received 6 upvotes till now... please select that answer as the correct answer of this question. – Rakib Feb 19 '14 at 06:36
  • hi @ilyo! Could you approve my answer on this please? It’s 7 years old and keeps helping people :) Thanx! – Martin Schaer Jul 04 '20 at 14:32

32 Answers32

253

Found solution for me here: Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

In my case my app crashed because I was hard setting the PORT, instead of using the port that heroku dinamicaly sets, which can be accessed with process.env.PORT

app.listen(process.env.PORT || 3000, function(){
  console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});
Community
  • 1
  • 1
Martin Schaer
  • 3,645
  • 1
  • 21
  • 26
60

I just had a similar issue with my app, I got the issue after a migration of the DB, after trying many options, the one that helped me was this:

heroku restart

(Using Heroku toolbelt for mac)

clarenswd
  • 863
  • 9
  • 17
17

I had this issue, the only problem was my Procfile was like this

web : node index.js

and I changed to

web:node index.js

the only problem was spaces

Sayandeep Majumdar
  • 301
  • 1
  • 8
  • 19
Arian Nargesi
  • 386
  • 3
  • 11
7

In my case, i found same error because there is version difference of node and npm on my local machine and defined in package.json version.

"engines": {
  "node": "0.8",
  "npm": "1.2.x"
}

when i check using

node --version : v0.10.41
npm --version : 1.4.29

when i update my package.json to

 "engines": {
  "node": "0.10.41",
  "npm": "1.4.29"
}

It works fine :)

Mahesh Singh Chouhan
  • 2,488
  • 1
  • 15
  • 26
5

in my case adding process.env.PORT || 3000 to my http server script, resolved. My heroku log reported 'H20' error and 503 http status.

Ewertom Moraes
  • 111
  • 1
  • 4
4

In my case, my Procfile was pointing to the wrong file (bot.js which I previously used) so once I updated it, the error was gone.

3

Also check your database connection. I forgot to change my database connection from localhost and this crashed my app once it was pushed to heroku.

lindsaymacvean
  • 4,131
  • 2
  • 17
  • 19
3

In my case there was no start command in the script section of package.json file. When I created the package.json file with npm init I did not create a start script command. So I went to the package.json file, under scripts I added a new entry:

 "scripts": {
    "start": "node index.js"
  },

Saved it and uploaded to Heroku and it worked

Valentin
  • 2,504
  • 1
  • 25
  • 38
3

upon using hapi18, I find taking out the "host" field and setting the port to:

port: process.env.PORT || 5000 did the trick.

3

Old Thread, but I fix this issue by setting PORT constant to process.env.PORT ||

For some weird reason, it wanted to search Env first.

Isaac Frank
  • 313
  • 3
  • 12
2

I faced this same problem and none of the answers above helped me. What i did was run:

node --version

and in the package.json add the engines section with your node version:

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "6.11.1"
  }
}
Martin De Simone
  • 2,080
  • 3
  • 15
  • 30
2

I had a typo

const PORT = process.env.PORT||'8080';

used to be

const PORT = process.env.port||'8080';

Omar
  • 2,494
  • 2
  • 28
  • 54
2

If you locally start node server by nodemon, like I did, and it locally works, try npm start. Nodemon was telling me no errors, but npm start told me a lot of them in a understandable way and then I could solve them by following another posts here. I hope it helps to someone.

Erik
  • 160
  • 2
  • 10
1

In my own case, i got this error because i refuse to add a Procfile to my node js app and my "main": "app.js" was initially pointing to another js file as main. so doing these chnages get it fixed for me

Forest baba
  • 169
  • 4
1

In my case, I forgot to set database env for deployment. you can set env by this command (I'm using mLab for MongoDB server)

heroku config:set MONGO_URI='mongodb://address'

minjun youn
  • 21
  • 1
  • 7
1

For me it was Package.json it was empty from dependencies even though i thought i did install them.. so I had to reinstall them with --save option in the end and verify they were added to the package.json.. and then push it again and it worked.

Roman
  • 11
  • 1
1

My port was set to config.httpPort which resolves to 80. I fixed it by doing this:

const PORT = process.env.PORT || config.httpPort;

app.listen(PORT, ...)

Thanks a lot, it wasted me a lot of hours last night.

Tamal Web
  • 124
  • 7
1

In my case I had code=H10 and status=503 because my Procfile:

web: node build/server.js

and I included /build in .gitignore

Donovant
  • 2,807
  • 8
  • 39
  • 64
1

My start command had env-cmd -f ./config/prod.env node index.js.

after changing to: node index.js it got fixed.

Itay Tur
  • 745
  • 11
  • 26
1

I got the same issue, the problem was my Profile was like this:

web: gunicorn__init__:app

Notice with the above there was no space between gunicorn and __ init __

instead of web: gunicorn __init__:app

0

I got the same above error as "app crashed" and H10 error and the heroku app logs is not showing much info related to the error msg reasons. Then I restarted the dynos in heroku and then it showed the error saying additional curly brace in one of the index.js files in my setup. The issue got fixed once it is removed and redeployed the app on heroku.

Stephen Kennedy
  • 18,869
  • 22
  • 90
  • 106
Praveen
  • 37
  • 7
0

Password contained a % broke it for me.

Nash Worth
  • 2,456
  • 1
  • 18
  • 27
0

The H10 error code could mean many different things. In my case, the first time was because I didn't know that Heroku isn't compatible with Sqlite3, the second time was because I accidentally pushed an update with Google analytics working in development as well as production.

Stephen Kennedy
  • 18,869
  • 22
  • 90
  • 106
0

Older thread, but for me I didn't set my .env vars in the Heroku console.

Josh Lavely
  • 318
  • 1
  • 3
  • 10
0

i was using body-Parser that throw exception

const bodyParser = require('body-Parser')    
//Bodyparser Middleware
app.use(bodyparser.json())

intead of using

    //Bodyparser Middleware
    app.use(express.json())

this resolved my issue

S.Sid
  • 1,302
  • 3
  • 15
  • 29
0

I want to register here what was my solution for this error which was a simple file not updated to Github.

I have a full stack project, and my files are structured both root directory for backend and client for the frontend (I am using React.js). All came down to the fact that I was mistakenly pushing the client folder only to Github and all my changes which had an error (missing a comma in a object's instance in my index.js) was not updated in the backend side. Since this Heroku fetches all updates from Github Repository, I couldn't access my server and the error persisted. Then all I had to do was to commit and push to the root directory and update all the changes of the project and everything came back to work again.

Luis Febro
  • 1,416
  • 11
  • 21
0

I struggle with the same error for hours, but I was able to solve it. I installed multer and aws-sdk as a devDependencies by mistake, instead of just dependencies. So, anyone who has the same error, just double-check your package.json file.

Also, a small tip for the property of the engine in package.json.

enter code here
//The greater or equal operators will make sure that you use the right node 
//version 
//even if your current node is greater version than npm node

"engines": {
"node": ">= 0.8.14"
},


//insted of
"engines": {
  "node": "0.8.14"
}
0

I was deploying python Django framework when I got this error because I forget to put my app name web: gunicorn plaindjango.wsgi:application --log-file - instead of plaindjango

Talha Anwar
  • 1,853
  • 2
  • 14
  • 36
0

For me, I had things unnecessarily split into separate folders. I'm running plotly dash and I had my Procfile, and Pipfile (and lock) together, but separate from the other features of my app (run.py and app.py, the actual content of the pages being used was in a subfolder). So joining much of that together repaired my H10 error

Tclack88
  • 51
  • 6
0
// PORT
const PORT = process.env.PORT || 8081;

// Listen on port 8081
app.listen(PORT, () =>
  console.log(`Application is listening on port ${PORT}!`)
);

process.env.PORT will handle whatever port is needed on, for example, Heroku, AWS etc.

Clancinio
  • 484
  • 1
  • 7
  • 25
0

In my case it was due to the heap memory limit.

  1. Just add some of the dependencies to the dev dependencies object.
  2. Remove unused modules.

You can see the exact error using heroku restart and if it is the memory limit, then upgrade your heroku account.

Nagibaba
  • 2,919
  • 1
  • 27
  • 34
0

in my case the problem solved by changing the order : From : app.listen(2000 || process.env.PORT); to : app.listen(process.env.PORT || 2000);

othmane-be
  • 42
  • 5