Programming is bittersweet.
It is very tedious and many a time, it can leave developers very frustrated with little zeal for another keypress.
Ho...
For further actions, you may consider blocking this person and/or reporting abuse
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"
}
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...
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
Works like a charm
Thanks for this it was helpful
yes!!! Thank you so much!! yes yes yes yes
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.
You rock!!!!
It was my issue too!!!! :D
Thank you so much! That helped fixed the error I was getting!
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 openwaiting 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
Glad to hear you resolved your isssue.
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
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.
Glad to add this to the list parables
Hello Parables could you be more specific about what the typo was? I am very happy to update my list.
Thanks.
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.
Thanks for this pro tip.
"
e.g
Wrong: web : node index.js
Correct web:node index.js
"
actually....
correct: web: node yourEntryFile.js
I was diagnosing an h10 error when I stumbled upon this post. Lots of great information, but a small error in the post sent me on a wild goose chase! In the above excerpt the wrong and correct syntax are actually reversed. the correct syntax in your Procfile should be web: node server.js server.js is just what I named my entry point and is not mandatory. What is, however, is the space between the colon and node.
I have found out that my original problem was incorrect imports between my components leading to the original h10 error. When I tried to fix it I changed my Procfile to the "correct" way mention in this post. Then later also fixed my imports. With the error still persisting I used Uros Randelovic's solution. Surprise, it worked! However, this solution was only masking the fact that in an attempt to fixed the h10 due to other issues, I changed my Procfile incorrectly to not include a space, then Uros Randelovic's solution circumvented the fact that Heroku didn't know how to start my file with a misconfigured Procfile and used the older syntax in the package.json file to correctly launch the app.
In summary if your Profile, captial P also import has web: node server.js ...or whatever filename you want to name your entry point, and a package.json file that looks like this for you scripts section...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
Heroku automagically looks for "build" now. Make sure you heroku config:set your env vars from CLI
eg. heroku config:set KEY=VALUE examples of KEY=VALUE pairs would be your database config, secret key for auth, etc.. and finally properly configure the JS in your entry point. In this example my entry is server.js with the following important code
const express = require("express");
const path = require("path");
const favicon = require("serve-favicon");
const logger = require("morgan");
require("dotenv").config();
require("./config/database");
const app = express();
app.use(logger("dev"));
app.use(express.json());
app.use(favicon(path.join(dirname, "build", "favicon.ico")));
app.use(express.static(path.join(dirname, "build")));
app.use("/api/users", require("./routes/api/users"));
app.get("/*", function (req, res) {
res.sendFile(path.join(__dirname, "build", "index.html"));
});
const port = process.env.PORT || 3001;
app.listen(port, function () {
console.log(
express app running on port ${port});});
make sure you require and install important modules, config your env and database, properly assign your port variable for either production or development and configure your server to return your index.html from the build folder when given any path.
I just solved this problem in my app and I consider it a big win
process.env.PORT👍heroku restartmultiple 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!
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]
I was getting same error for a react app templated by create-react-app.
I resolved it by changing buildpack to github.com/mars/create-react-app-b... .
Above build pack is required for create-react-app template (static sites).
In Heroku dashboard, under settings> buildpack - I changed from node build pack to github.com/mars/create-react-app-b... and then react static web page started working (buildpack can be set via Heroku CLI also).
If your app is involving, node backend , then checkout github.com/mars/heroku-cra-node .
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:
heroku local -a <heroku-app-name>. Make sure you test everything to make sure nothing crasheshost: process.env.HOST || '0.0.0.0' || 'localhost'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
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
I found the solution add another buildpack with this:
heroku buildpacks:set mars/create-react-app
without it, my app doens't worked?
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!
Thanks a lot Robson for sharing this. Just worked for me after hours of near frustration
I have had the same problem. So, I coudn't find the solution yet.
Woooo! It's June 08, 2021 and this article keeps on giving. It worked for me! Thank so much.
Followed this exactly,
"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"
}
(start with npm run dev to run it locally )
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
Thanks Kaitlyn Rodriguez.
Thankyou so much man .I was searching for the solution for past 3 days.I m new to this and was stuck .My Procfile had an indentation problem and this quickly solved my prblem.
PS: Created an account here just to thank you.
Ran into same error message. app was deploying successfully but not opening.
Issue was I had .env as a soft link to a file outside the working folder (Ubuntu)
restored the actual file and it started working.
Somehow, if a file is needed by Heroku and it's a soft link and not the actual file, it breaks the app.
Something to keep an eye on in future.
I had nestjs and angular monorepo, and I was getting this error all of sudden after I created some new routes, before I wasn't building locally heruko, auto-built and deployed, and had my /dist in .gitignore, so I first built my app locally pushed dist folder to github, and after that app started working.
I don't really know why is that cause before hand last time I did tested it by creating some routes and it was all well. However try to see if it fixes for you.
I'm having problems with my heroku app and I have tried to update both node and the Heroku app and I have added the engines line so all that is left is the Procfile but there is no Procfile anywhere on my computer, does this mean that I have to create one and what should it look like?
Hello, Christian, I am very sorry for the late reply but I do hope if this doesn't come in at the nick of time the knowledge would be useful for your other projects.
The Procfile is always a simple text file that is named Procfile without a file extension.
This means that; Procfile.txt is not valid. And don't forget that capitalized "P". As for the content below is a configuration from one of my Procfile.
web:node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js
cheers.
Thank you, updateing the scripts resolved it for me!
Hi ,
We are having an issue initializing the app which was created on Heroku (and worked perfectly for months). We did not touch or deploy any files (we were only adding the content).
Sometimes we get this error in the heroku logs
2021-05-09T11:26:39.184283+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sws-wiki.herokuapp.com request_id=4a1aba64-a4c0-4a1e-8bb4-231d3cc51bbb fwd="95.180.36.112" dyno= connect= service= status=503 bytes= protocol=https
2021-05-09T11:26:39.985839+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sws-wiki.herokuapp.com request_id=44a1adc6-1f14-4434-b8f7-514216845fdd fwd="95.180.36.112" dyno= connect= service= status=503 bytes= protocol=https
and sometimes this one.
Error: Cannot find module '/wiki/logs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
We have tried:
heroku restart
2021-05-09T11:39:03.848687+00:00 heroku[run.5087]: Awaiting client
2021-05-09T11:39:03.868781+00:00 heroku[run.5087]: Starting process with command
restart2021-05-09T11:39:03.872682+00:00 heroku[run.5087]: State changed from starting to up
2021-05-09T11:39:08.263164+00:00 heroku[run.5087]: Process exited with status 1
2021-05-09T11:39:08.325802+00:00 heroku[run.5087]: State changed from up to complete
2021-05-09T11:40:45.464779+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sws-wiki.herokuapp.com request_id=edfca19c-949e-4e13-b496-adcd6e33286b fwd="95.180.36.112" dyno= connect= service= status=503 bytes= protocol=https
2021-05-09T11:40:46.514332+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sws-wiki.herokuapp.com request_id=bbf65ba8-ecb4-47cd-ace8-83f0e8b66791 fwd="95.180.36.112" dyno= connect= service= status=503 bytes= protocol=https
and npm install -g
Please advise. Thanks
Hello, first of all thanks for sharing. I am new with backend development and I decided to start with Go. I deployed an API to Heroku but can't seem to figure out how to connect my app to it, and so far I am receiving the error you are mentioning. Can I contact you regarding some issues?
I have tried everything I could but my node app wouldn't work on Heroku even though it works perfectly locally.
I attached the image of my www file for somebody who has any idea(s) to help me look at it if it is wrong or right.
PS: This is what I use locally and it is working perfectly.
I added an image but it is not displaying.
2020-04-05T10:21:57.147854+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-falls-48795.herokuapp.com request_id=c29b11d5-31c1-4514-9aec-15a792a9e481 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:22:02.304817+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-falls-48795.herokuapp.com request_id=c7100355-3ae2-40ef-a328-46526390af03 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:24:00.377844+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-falls-48795.herokuapp.com request_id=27532abb-087f-4262-bb6d-5a22d511f0ee fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:24:01.003156+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-falls-48795.herokuapp.com request_id=bd1d2d51-3531-4f18-a345-c600410a1f93 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:24:03.924761+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-falls-48795.herokuapp.com request_id=8ddfe113-d6ab-4e80-a875-f632ab4b0a67 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:24:05.323501+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-falls-48795.herokuapp.com request_id=a3dd077d-28cc-42be-b86e-52c4aa69bdf9 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:24:44.133118+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-falls-48795.herokuapp.com request_id=313e668d-4e4d-4069-a2e0-c25f06ba6f20 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:24:44.706001+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-falls-48795.herokuapp.com request_id=ef9591ce-8358-4c7e-8f74-4629b64ddeba fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:35:22.282511+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-falls-48795.herokuapp.com request_id=b9c0338d-00e7-4291-acba-327ab78811f8 fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T10:35:22.981007+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-falls-48795.herokuapp.com request_id=ec4c732c-9e32-4e8c-9fb1-04b70c07bffc fwd="154.118.6.176" dyno= connect= service= status=503 bytes= protocol=https
Same error man! Did you get a way to solve it?
Hey all,
I tried with
npm install serve --sand replacing my scripts in package.json, but when tested both on my local machine and heroku while runnpm run start, after build, I got an error:However, if I run it manualy by typing
serve -s buildit works, but it uses an old version of serve@^6.14.6I tried to install this verion and deploy to heroku but it's saying that there is no such a verion.
Any thoughts on what it could be, and maybe how I can solve this?
Thanks in advance!
My pachage.json:
Thank you a lot!!
This was really helpful Thanks
Thanks a lot! I made a mistake in procfile and nowhere in the world i was going to get this fixed! Thanks a lot! Saved a lot of time!
Cool tips, the last one works for me! Thanks a lot
You are welcome. I glad this helped you out.
This was really helpful, thank you very much.
Indeed, the error was in the procfile
Hello everyone, I am getting the following error after deploying my app:
at=error code=H10 desc="App crashed" method=GET path="/" host=panthercrushlist.herokuapp.com request_id=77e3b920-d152-45c6-a908-bd7f2e58c76b fwd="140.233.174.71" dyno= connect= service= status=503 bytes= protocol=https
2021-04-29T20:05:15.230672+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=panthercrushlist.herokuapp.com request_id=6700b59a-f7fe-4864-a163-41a31b6cee50 fwd="140.233.174.71" dyno= connect= service= status=503 bytes= protocol=https
2021-04-29T20:34:09.456725+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=panthercrushlist.herokuapp.com request_id=4c53459a-ad78-4ba5-973b-e7f2864711c5 fwd="140.233.174.71" dyno= connect= service= status=503 bytes= protocol=https
2021-04-29T20:34:09.959440+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=panthercrushlist.herokuapp.com request_id=365fd8cb-9498-4b51-a59b-022ef919e708 fwd="140.233.174.71" dyno= connect= service= status=503 bytes= protocol=https
And I have NO IDEA how to approach it. Can someone help please?
Thank you in advance.
In my case I updated one of the API keys and forgot to swap it in the Heroku Config Vars of the project. Thanks for the article!
Thanks a lot for this article, although I might end up doing the Unthinkable :/ .
This was really helpful, thank you very much.
Thanks. I am glad you find it helpful.
I am getting a H10 error, in the app.get('/') portion with a /favicon.ico error! I have no idea about it and ik there's a icon for the title but i didnt touch it in the whole project still its causing error
i am getting this error -
2021-01-12T10:58:37.082589+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nsb-inter-city-bus.herokuapp.com request_id=32b771a0-adcb-454c-ac96-f5281358c0c5 fwd="103.25.251.235" dyno= connect= service= status=503 bytes= protocol=https
2021-01-12T10:58:37.552199+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nsb-inter-city-bus.herokuapp.com request_id=1000b780-50ad-4a96-87b7-7b1f2e1bf562 fwd="103.25.251.235" dyno= connect= service= status=503 bytes= protocol=https
in my package.json-
"scripts": {
"heroku-postbuild": "ng build --prod",
"ng": "ng",
"start": "node index.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"engines": {
"node": "12.18.2",
"npm": "6.14.5"
},
in my Procfile-
web: node index.js
what is the solution please??
Save lives! thanks!
Thnx never thought about wrong spacing in Procfile
I was stuck on H10 for a month,
My Fix was comment out all the dev dependencies
i just registered myself to only Thank you coz you saved my life .
Thanks! This helped me a lot.
I am getting the following error it has been the whole day but I am not able to resolve this please help (This is for my 1st webD project):-
Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch '/app/Problem_Set/Problem_urls/problem_url_1349.txt'
settings node version by using
saved me lots of headaches, thanks man
What solved the problem for me (react with typescript project):
Clientside:
Serverside:
"start": "ts-node --transpile-only [your entry file].ts",
(leave out the --transpile-only flag if you don't have any type issues remaining)
more about the issue:
stackoverflow.com/questions/620962...
moved ts-node and typescript out of dev dependencies in package.json
(this time all @types/... can remain in dev dependencies )
[also added to package.json, but I have not checked if this one is crucial]
"engines": {
"node": "14.x"
},
you.. Mr. Lawerence - are a savior! May your rest of 2020 be wonderful!
Very clean and understandable, worked in first try. Thanks
I cannot thank you enough for this! For me it turned out to be my Procfile pointing to the wrong server file and missing start script in my package.json. Thank you Lawrence!!
I am glad this helped you solve your problem.
i get the same app crashed...im using Flask in Heorku
Thank you man, it was so useful.
Had to login just to thank you. You saved my skin today, mate! Cheers!
love the "Heroku restart" option... KISS as usual :)
thank you so much Lawrence! this worked like magic
Thank you. this was very helpful for me.
Thanks
i have a question, my scripts section in package.json don't contain a "heroku-postbuild": "npm run build", would this affect my deploy to heroku ?? @lawrence_eagles
Ran into this on my Django app. Later on, realized I had not installed gunicorn 😂
Just rerun build again .. this will solve the problem
I found this article very useful, thank you very much
Declaring my mongodb database on heroku solved my issue. I was having H10 error with 503 status.
Thank you very much, it was a Bug in the Procfile for me. This took me allot of hours.
Cheers
Thank you this helped me out a lot!
Broo thank you so so much i was freking out with deployment and your solution still works in Sep 2022 thank you so much i just create account to say thanks!
please is the solution different when deploying flask web app.
Because i dont have an issue with my procfile yet i get an h10 application error
No matter you believe or not, I tried everything mentioned here, but the error persists
This was really helpful to me. Turns out my issue was from setting a port without the process.env variable option, which I already had set up.
Thank you!
Thanks a lot bro. You saved my code.Twice.