DEV Community

Cover image for Causes of Heroku H10-App Crashed Error And How To Solve Them
Lawrence Eagles
Lawrence Eagles

Posted on • Edited on

Causes of Heroku H10-App Crashed Error And How To Solve Them

Programming is bittersweet.
It is very tedious and many a time, it can leave developers very frustrated with little zeal for another keypress.

However, developers are always having a whale of a time while coding, and they are full of pride and joy, once all their codes run successfully without errors.

That being said no one wants to be frustrated while coding hence no one wants bugs in their codes.
alt text

Developers, often do not get it all right ("code-wise") at first try; consequently, the software development cycle involves debugging, refactoring, upgrading, and many other enhancement operations.
In addition, developers know that many a time we all have to deal with bugs in our code. Hence debugging is an invaluable skill in a developer's repertoire. And to be successful at debugging, we need a good understanding of error messages.

Error codes or messages are the ways computers inform us that there are bugs in our codes, and sometimes it tells us where they are.

The paradox is that error codes; although are very helpful, they are not plain English and can be very confusing and cryptic

Below are error codes from a crashed app on Heroku.



2019-10-11T11:27:28.019054+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=realtylabapp.herokuapp.com request_id=74165d9f-db2a-46bd-ab9c-1a01403bd00f fwd="129.205.113.108" dyno= connect= service= status=503 bytes= protocol=https
2019-10-11T11:27:29.919409+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=realtylabapp.herokuapp.com request_id=fa48efa2-4ddf-41e6-a633-a62cb02314bd fwd="129.205.113.108" dyno= connect= service= status=503 bytes= protocol=https


Enter fullscreen mode Exit fullscreen mode

Heroku uses a unique alphanumeric error code combo to communicate to the developer the kind of error that was found in their code.

This alphanumeric error code ranges from:

  1. H10 to H99
  2. R10 to R99
  3. L10 to L15

Get a detailed list here: Complete Heroku Error Codes

This article is focused on the Heroku H10-App crashed error code which is thrown when an application crashes on Heroku. This is as much as it goes. It does not help us with the reason our app crashed and that's where this article comes in. Below are some causes of this error and I guarantee you that some of them would surprise you greatly!

  1. Bug in Procfile
    A very interesting discovery for me. A bug in your Procfile can crash your app. If your Procfile is pointing to the wrong server file. e.g If your server is in server.js and your Procfile points to app.js this would definitely crash your app and Heroku would greet you with the H10-App crashed error code message.
    Secondly, a buggy Procfile can also come in the form of wrong spacing. e.g
    Wrong: web : node index.js
    Correct web: node index.js

  2. Setting a PORT as a Heroku environment variable
    This would surely crash your app. Heroku automatically sets a Port that can be accessed via process.env.PORT. Setting a port yourself would crash your app. Surprisingly, the command heroku config does not display the preset Heroku port so one might be tempted to set another port as an environment variable.
    To see all the preset Heroku environment variables, use the command heroku run printenv.

  3. Missing Required Environment Variable while setting a port would cause this error because Heroku already sets a port internally, failing to set any required environment variable (e.g your database), would prompt Heroku to greet you with this error.

  4. Missing Required Scripts
    This error is thrown in a Node.js environment if you forget to set a start script. Heroku uses this script to start your app so if it is missing, it would throw an H10-App crashed error code message.

This can be solved by setting a start script in the package.json. e.g



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



Enter fullscreen mode Exit fullscreen mode

Final Thoughts
If none of the above solved your problem, you can make a last-ditch attempt by updating all your packages. If this doesn't help and you are in a Node.js environment, your last resort would be setting a node version in the engine section of your package.json file.



{
 "name": "myapp",
 "description": "a really cool app",
 "version": "1.0.0",
 "engines": {
   "node": "12.11.1"
   }
}


Enter fullscreen mode Exit fullscreen mode

The Unthinkable
Lastly, if your bug defiles all solution, and by this time you are grasping at straws; I leave you in the able hands of heroku restart.

Let me know if you have experienced any other cause of this error in the comment below.

Top comments (130)

Collapse
 
urosran profile image
Uros Randelovic • Edited

Up until recently I was able to deploy development build to Heroku and since couple of days ago even out-of-the-box npx create-react-app would fail with H10 code - solution was to ofc deploy the production build like below:

npm install serve --s

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

Collapse
 
daleluce profile image
DaleLuce

Looks like i picked a bad time to attempt to deploy my first web app. Does this mean I need to run this line in my command module "npm install serve --s"

and then copy this into my package.json exactly as is?

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

I tried to do that and it didn't work when I went to update the master on heroku.
Thanks in advance...

Collapse
 
cmarshman profile image
Cory Marshman

As of May 23rd, 2020. This fix worked beautifully. I've never had any issues pushing to heroku until my most recent project. This was perhaps my 4th or 5th attempt to fix it and this work amazingly. Thanks DaleLuce

Thread Thread
 
efecollins profile image
Efosa Collins EVBOWE

Works like a charm

Collapse
 
hickeymonster profile image
Emmanuel Okwuzi

Thanks for this it was helpful

Collapse
 
hickeymonster profile image
Emmanuel Okwuzi

Thank you!. This worked!

Collapse
 
maskoul profile image
Mohamed Maskoul

@daleluce Thank you so much thank uuuu!! i spent all the day to fix this problem i tied so many solution on internet but only your solution worked!! i was give up but you saved me, i made the account now to thank you <3

Thread Thread
 
daleluce profile image
DaleLuce

Thanks for letting me know Mohamed! This made my day!

Collapse
 
danielfruitspec profile image
DanielFruitSpec

yes!!! Thank you so much!! yes yes yes yes

Collapse
 
hadarose profile image
Hadar Rosenman

Worked like a charm after 2 days of frustration! Thank you!!!

Thread Thread
 
jaytailor10 profile image
jaytailor10

I made this app without authentication and there was no problem deploying it on heroku but now I have added authentication to it and heroku is creating trouble. Looks like I am gonna stuck here for weeks.

Collapse
 
diegobonfim182 profile image
Diego Bonfim Da Silva Fernandes

Yessss!!! It works to me.
Your are an angel!
Saved my week.

Thanks in advance...

Collapse
 
chandanxp profile image
Chandan

24-Aug-2020 : I tried this fix and this worked for me ,
1.) "npm install serve --s" in my terminal

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

2.) copied the above code("scripts") in place of my previous code "scripts" in my package.json file
3.) git commit -am "new update"
4.) git push heroku master

and Boom I found my wesite on herokuapp
thank you very much

Collapse
 
guilhermebodart profile image
Guilherme-Bodart

Pros BR's de plantão, isso aqui ainda funciona, fiz aqui no meu e meu deploy deu certo, caso esteja assim no seu,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
use o npm install serve --s e altere igual ao comentário a cima.

THAT STILL WORKS ON 30/01/2020

Collapse
 
tjombell profile image
Tjomb Bell

It works for me thank you very much !!!

Collapse
 
saimaar profile image
Saima Rahman

This worked like magic! Thank you so much!

Collapse
 
moazamdev profile image
Moazam Ali

Thank you for providing this steps, It also worked for me

Collapse
 
ajgcph2019 profile image
ajgcph2019

Thank you.This worked for me

Collapse
 
dalisc profile image
Dalis Chan

THANK YOU!!! i created this account just to thank you because I had so so much trouble deploying. Build was fine but after build when heroku tried to run start, I ran into so many H10 and H12 errors and the app can't even display a static page.

Your solution worked PERFECTLY!

Collapse
 
haimbuchbut profile image
Haim Buchbut

Thanks. It solved my problem on Heroku, but I can't run my app locally.
After installing serve and modifying package.json, when I run npm start - serve says the app is available on port 5000 but I'm getting 404 page there. (it doesn't work also on port 3000 which was the one that I used so far).
Any ideas why?

Collapse
 
urosran profile image
Uros Randelovic • Edited

Hi Haim,

If you run yarn start/npm start now it points to 'serve -s build' instead of 'react-scripts start'.

Make sure you've added below:

"dev": "react-scripts start",
"start": "serve -s build",

and to run your app locally do npm run dev not npm start

Thread Thread
 
haimbuchbut profile image
Haim Buchbut

Thanks. It didn't work with "npm dev" (I got that "dev" is invalid command), but it did work with "npm run dev".

Thread Thread
 
lawrence_eagles profile image
Lawrence Eagles • Edited

I am glad to hear this worked for you.
Just a side note:
commands like npm start can work directly because they are default commands from npm but custom commands like dev set by the user would only work with the run command. npm run dev. I hope this clears things up.

Collapse
 
marcosaponaro profile image
marcosaponaro • Edited

Thanks a lot, now deploy on Heroku is working! But I've found another issue. Changing from npm start to serve -s build the local solution (npm run dev) is the correct one but the one on Heroku is not the same (is something like the first beninning project template). Why this difference? I've tried with a npm run build command but no difference. Thank you

Collapse
 
jdrichardstech profile image
JD Richards

This was a lifesaver. Thanks!

Collapse
 
coltonkaiser profile image
Colton Kaiser

This worked!!

Collapse
 
radkin profile image
Noel Miller

Thanks. You saved me a lot of time and trouble.

Collapse
 
joejcox profile image
Joe Cox

Hero!!! Thank you!

Collapse
 
ezzaffa88 profile image
SOFIEN

Really thank you Very Much you saved my Wasted Time with installing serve and calling it on start script

Collapse
 
danielfruitspec profile image
DanielFruitSpec

Finally! it worked!! Thank you so much!!!!

Collapse
 
hickeymonster profile image
Emmanuel Okwuzi

Thanks a lot!

Collapse
 
starkky07 profile image
Kishan Sahu

Thank you very much. Now it serves like a charm.

Collapse
 
uzairjan profile image
Uzair Khan

Thanks dude.

Collapse
 
sayanta2702 profile image
Sayanta Bhattacharje

This worked ...Thanks for saving a day's work

Collapse
 
rohit_rambade profile image
Rohit Rambade

Thank You !!!

Collapse
 
marlieer profile image
marlieer

Thank you!!! This solved it

Collapse
 
davidgoodson profile image
Buyinza David

Wow.. this worked like a charm.

Collapse
 
lucianonahuel4528 profile image
Lucianonahuel4528

Thanks my brother....
Greetings from Argentina Corrientes

Collapse
 
marlonx19 profile image
Marlon Englemam

I have no idea why, but install serve --s solved the issue!!! Why is that??
I have many other older react apps running normally on heroku without needing to install serve --s

Collapse
 
sagarkharabe profile image
Sagar Kharabe

Same happened to me. Do you know why this is happening?

Collapse
 
urosran profile image
Uros Randelovic

We can only speculate, React was updated on March 20th and around then it stopped working so I am guessing there is something that is happening with webpack or whatever was successfully serving our apps.

Collapse
 
ch1zo profile image
chizo nwazuo

Thank you sooo much! This sure saved me a lot of frustration. Was wondering if you could give a bit of insight about how you figured out this solution

Collapse
 
urosran profile image
Uros Randelovic

If you look at the logs it says 'starting development server' - given that if we deploy something to heroku we want it to be prod environment for variety of reasons (stackoverflow.com/questions/481511...). I looked at the versions of react and it so happened that react itself was upped a version 2-3 days prior to my attempt to deploy so I realized that whatever heroku was doing before to serve the build server obv somehow broke so I decided to change it to prod build (which I should have done from the get go but never cared as I just wanted to send the app to friends)

Collapse
 
nelsong1997 profile image
Gabe N

I spent many hours troubleshooting and this ended up working. Thank you!!

Collapse
 
moidhasanbeig profile image
Moid Hasan Beig

The same occurred with me. Thanks for this solution.

Collapse
 
lawrence_eagles profile image
Lawrence Eagles

I am glad this helped you resolve your issue.

Collapse
 
raqgoth profile image
Raquel Gothardt

Thank you soooo much!!!! this worked!!! ater 2 days of being stucked!!!!

Collapse
 
monatyagi profile image
MonaTyagi

It worked for me, thanks a lot !

Collapse
 
diegobonfim182 profile image
Diego Bonfim Da Silva Fernandes

Thanks Dude.... you are an angel!!
Saved my week!!

Thanks in advance...

Collapse
 
fbaralle profile image
Francisco

Hi everyone, i was running on the same problem of H10 and H20 errors. The app was working fine (package.json "start" declared correctly, no Proclife needed) on my goorm IDE container, no errors (using mongo Atlas - cloud Database), and runing on the local port 3000. But every time I tried to deploy it in heroku it was constantly giving back these annoying errors.

Then I checked some threads on stack overflow and found the solution here
stackoverflow.com/questions/186796...

My app listening on port 3000 like this.

//app.listen(3000, function () {
// console.log("Yelp Camp Server running on Port 3000")
// });

I thought it was fine but then i tried writing it in some other way i found in the answers of that thread.

app.listen(process.env.PORT || 3000, function() {
console.log('Server listening on port 3000');

});

AND THIS SOLVED MY PROBLEM. I actually couldn't find why it wasn't working correctly on heroku (because it worked fine on my local environment), but I'm so glad its running ok now.

Hope my solution can help someone.

Collapse
 
gindev77 profile image
gindev77

You rock!!!!

It was my issue too!!!! :D

Collapse
 
danieljimenez0255 profile image
Daniel Jimenez

Thank you so much! That helped fixed the error I was getting!

Collapse
 
parables profile image
Parables

Programming is bittersweet indeed!!!

Thanks for publishing this article... I wanted to get my hands dirty by building a graphql server and deploy it online. After the headaches writing resolvers, I finally had a final working version ready for deployment. My search led me to Heroku and I deployed in minutes. With only one command away I typed heroku open waiting for the magic to happen only to see "Heroku H10-App Crashed Error".

Never-giving-up, I came this far and nothing will stop me. I came across you article and I figured Number 2 was my cause...

See me doing some energetic dance moves here :-)

thanks so much.... very grateful

Collapse
 
lawrence_eagles profile image
Lawrence Eagles

Glad to hear you resolved your isssue.

Collapse
 
irudra profile image
Hemant Gaur

I got the same H10 app crashed but none of the above solutions worked for me. I have updated build back using this command it worked after that.

heroku buildpacks:set mars/create-react-app

Collapse
 
parables profile image
Parables

It happened again and this time, Number 2 wasn't the cause as I have already resolved that. I tried to run it locally and found out that, I made a typo in my code and it was crashing my app.
so I think you should add that to the checklist.

  1. Check your codes and debug it for any errors.
Collapse
 
lawrence_eagles profile image
Lawrence Eagles

Glad to add this to the list parables

Collapse
 
lawrence_eagles profile image
Lawrence Eagles

Hello Parables could you be more specific about what the typo was? I am very happy to update my list.
Thanks.

Collapse
 
abdulkhader profile image
AbdulKhader

hi i am getting below error ,eventhough i verified everything.
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sleepy-basin-67900.herokuapp.com request_id=f0e633ca-b51e-4b81-9d2f-11857b8d4e42 fwd="157.50.221.204" dyno= connect= service= status=503 bytes= protocol=https

Collapse
 
robson_dejesus profile image
Robson de Jesus

I found the solution add another buildpack with this:
heroku buildpacks:set mars/create-react-app

without it, my app doens't worked?

Collapse
 
c00ki35 profile image
Cooki3

Hi Robson,

Not sure what this command is but it worked for me, can see the app on screen at last (still errors) but on screen. Thanx!

Collapse
 
nwa_eneh profile image
Tony

Thanks a lot Robson for sharing this. Just worked for me after hours of near frustration

Collapse
 
robson_dejesus profile image
Robson de Jesus

I have had the same problem. So, I coudn't find the solution yet.

Collapse
 
parables profile image
Parables

Okay, am back again on how to check your app for errors. In my previous case, it was a wrong import or a typo(better use Typescript to avoid these small typos) that was causing my app to crash locally.Fixing that solved it for both localhost and Heroku. But I was here again today because of the H10 error. It seems your article has now become my checklist whenever a deploying to Heroku. so to add a few tips:

  1. Run your code locally using npm and also with heroku local -a <heroku-app-name> . Make sure you test everything to make sure nothing crashes
  2. If you use .env vars, make sure to set them up in the Heroku config vars and beware of unwanted spacing in your config values. (In one case, my MongoDB Atlas con string had some unwanted spaces in my config value)
  3. Depending on your sever(esp. for Hapi), you must set your host to this:

host: process.env.HOST || '0.0.0.0' || 'localhost'

  1. Don't give up, check community support for the framework, library etc you are using, you are no the only one who has been stuck on that annoying bug. A problem shared is half solved.

That was why I was here today: I switched from Express to Hapi (just curiosity sake) only to meet this H10 error again. After lot of hours and multiple tabs of StackOverflow answers, I went to the Slack community of Hapi to seek help. It was then that I found out I needed step 3 above so make community support your last option before you even think of giving up

Collapse
 
marinar profile image
Maryna Romaniuk

I've struggled for hours, but finally have figured out, that I run my app from dist/server.j, but dist folder was ignored in .gitignore file, thus has been never pushed to Heroku. You can check your published files by running heroku run bash -a [APP_NAME]

Collapse
 
bogicevic7 profile image
Dragoljub Bogićević • Edited

Regarding Procfile, web: node index.js should be ok as you can see in the official documentation devcenter.heroku.com/articles/gett...

Btw, good advice is to test your app locally before deploying because errors are much more readable, so run heroku local web to check out if everything is ok then deploy.

Collapse
 
lawrence_eagles profile image
Lawrence Eagles

Thanks for this pro tip.

Collapse
 
efecollins profile image
Efosa Collins EVBOWE

I just solved this problem in my app and I consider it a big win

  1. My Procfile was fine. It had no problems 👍
  2. I had a working heroku port using process.env.PORT 👍
  3. I was missing environment variable and I had to set it by Googling 😘
  4. I was also missing required scripts which I did set using your example 😁
  5. I had to restart my dynos using heroku restart multiple times and it turned out great.

This is my second time using heroku but my first time connecting it to a database.

I made a to-do list and it's URL is @ todo-list-234.herokuapp.com/

THANKS FOR YOUR HELP!