realpython / flask-boilerplate

Boilerplate template for a Python Flask application with Flask-SQLAlchemy, Flask-WTF, Fabric, Coverage, and Bootstrap
http://www.flaskboilerplate.com
Apache License 2.0
1.53k stars 535 forks source link

Deploying app on Heroku (code=H10 desc="App crashed") #14

Closed nop33 closed 8 years ago

nop33 commented 9 years ago

Hello, I followed the steps in your README file to clone the repo and deploy the app on Heroku. I immediately got the following errors when opening the website: Gist

Here's is the history of what I did exactly:

git clone https://github.com/mjhea0/flask-boilerplate.git
cd flask-boilerplate
virtualenv --no-site-packages env
source env/bin/activate
pip install -r requirements.txt
python app.py
heroku login
heroku create
git push heroku master
heroku open

The app is running properly on localhost. Did I miss something? Thanks

nop33 commented 9 years ago

I figured out that I have to use web: gunicorn app:app --log-file=- in the Procfile.

ni8mr commented 9 years ago

Hello @nop33 , i have faced same problem and i have applied your solution (by editing procfile). But the result is same. (Application Error on Heroku)

@mjhea0 , can you please look at this problem :)

mjhea0 commented 9 years ago

Can you see what the error is? Run - heroku logs.

ni8mr commented 9 years ago

@mjhea0 , here is my errors (from the error logs)-

I have three types of error.

At first- Error R10 (Boot timeout ) -> Web process failed to bind to $PORT within 60 seconds of launch. Heroku R10 Error- https://devcenter.heroku.com/articles/error-codes#r10-boot-timeout

After that, i have a H20 error- desc="App crashed" method=GET path="/favicon.ico" host=.... request_id=... fwd=.... dyno=connect=service=status=503 bytes= (blank) Heroku H20 error- https://devcenter.heroku.com/articles/error-codes#h20-app-boot-timeout

Then, i have a H10 error-- desc="App crashed" method=GET path="/favicon.ico" host=.... request_id=... fwd=.... dyno=connect=service=status=503 bytes= (blank) Heroku H10 error- https://devcenter.heroku.com/articles/error-codes#h10-app-crashed

mjhea0 commented 9 years ago

Your procfile is not correct. Can I see your code.

On Wed, Jul 15, 2015 at 11:57 AM, Noor Faizur Reza <notifications@github.com

wrote:

@mjhea0 https://github.com/mjhea0 , here is my errors (from the error logs)-

I have three types of error.

At first- Error R10 (Boot timeout ) -> Web process failed to bind to $PORT within 60 seconds of launch. Heroku R10 Error- https://devcenter.heroku.com/articles/error-codes#r10-boot-timeout

After that, i have a H20 error- desc="App crashed" method=GET path="/favicon.ico" host=.... request_id=... fwd=.... dyno=connect=service=status=503 bytes= (blank) Heroku H20 error- https://devcenter.heroku.com/articles/error-codes#h20-app-boot-timeout

Then, i have a H10 error-- desc="App crashed" method=GET path="/favicon.ico" host=.... request_id=... fwd=.... dyno=connect=service=status=503 bytes= (blank) Heroku H10 error- https://devcenter.heroku.com/articles/error-codes#h10-app-crashed

— Reply to this email directly or view it on GitHub https://github.com/mjhea0/flask-boilerplate/issues/14#issuecomment-121693471 .

ni8mr commented 9 years ago

Hello, i have cloned the exact code from Github and than tried it on Herkou. I have attached my code with this mail.

My app link: ni8mr2.herokuapp.com

On Thu, Jul 16, 2015 at 8:08 PM, Michael Herman notifications@github.com wrote:

Your procfile is not correct. Can I see your code.

On Wed, Jul 15, 2015 at 11:57 AM, Noor Faizur Reza < notifications@github.com

wrote:

@mjhea0 https://github.com/mjhea0 , here is my errors (from the error logs)-

I have three types of error.

At first- Error R10 (Boot timeout ) -> Web process failed to bind to $PORT within 60 seconds of launch. Heroku R10 Error- https://devcenter.heroku.com/articles/error-codes#r10-boot-timeout

After that, i have a H20 error- desc="App crashed" method=GET path="/favicon.ico" host=.... request_id=... fwd=.... dyno=connect=service=status=503 bytes= (blank) Heroku H20 error- https://devcenter.heroku.com/articles/error-codes#h20-app-boot-timeout

Then, i have a H10 error-- desc="App crashed" method=GET path="/favicon.ico" host=.... request_id=... fwd=.... dyno=connect=service=status=503 bytes= (blank) Heroku H10 error- https://devcenter.heroku.com/articles/error-codes#h10-app-crashed

— Reply to this email directly or view it on GitHub < https://github.com/mjhea0/flask-boilerplate/issues/14#issuecomment-121693471

.

— Reply to this email directly or view it on GitHub https://github.com/mjhea0/flask-boilerplate/issues/14#issuecomment-121967393 .

mjhea0 commented 9 years ago

@ni8mr - is this still an issue?

ni8mr commented 9 years ago

@mjhea0 , I didn't try it later. So this is not an issue for me now.

mjhea0 commented 9 years ago

any chance that you could test it again?

ni8mr commented 9 years ago

@mjhea0 , sorry for late reply. I have tried deploying it just now. Error (Application Error) remains. So i think it is still an issue.

rlynjb commented 8 years ago

having the same issue guys.. was there any solution for this?

ubeliciousgrace commented 8 years ago

I'd be interested in knowing the solution for this. I build a node app, using reactJS. when i deployed to Heroku, i got the similar issue. I think it has to do with the asset thing. Can anyone explain me how to solve this problem?

marcosicp commented 8 years ago

any news?

mjhea0 commented 8 years ago

@marcosicp try now. Procfile has been updated.

taysvea commented 8 years ago

Please help I have the Procfile in my repo but I am still getting the H10 error. I have no idea why.

taysvea commented 8 years ago

https://secret-bayou-86441.herokuapp.com/

mjhea0 commented 8 years ago

I need to see your code. Post a link please.

taysvea commented 8 years ago

https://github.com/taysvea/TwitterBot

mjhea0 commented 8 years ago

At the very least I need to know how to get this app running locally:

When asking for help, you need to make it easy for one to help you. It will take me up to an hour to figure out how to get this running locally - which is not even the issue for you. Update the readme, then reply here.

dulajsan commented 7 years ago

still having same problem. restarting heroku doesn't solve the problem.

miPlodder commented 6 years ago

In the Procfile,

Add correct name of the main routing file, here <_main-routing-python_>

web: gunicorn <_main-routing-python_>:app

celikmustafa89 commented 6 years ago

THIS SOLUTION IS FOR GO When you deploy an app through heroku, it does not allow you to specify the port number.
In other words, you can not specify your web service's port number as 8000 or something else, heroku decides the port number in runtime.
so, you can not use the following code:

    log.Fatal(http.ListenAndServe(":8000", router))

What you can do is, getting the runtime port of heroku.
In short, just use the following code:

    log.Fatal(http.ListenAndServe(":" + os.Getenv("PORT"), router))
jacobsteenhuysen commented 6 years ago

where? in Procfile?

vialyx commented 5 years ago

@celikmustafa89 Thank you! It works!

PraveenAsh commented 5 years ago

Set the PORT numbers dynamically rather than a hardcoded value

The issue is Heroku will provide a port number for your app. But if you have hardcoded the port numbers in your code then there will conflict b/w assigned and usage port. So, if it is running on another port, if you fetching file(ie favicon or '/') from another port it crashes with an error of H10.

FIX: If in node.js try process.env.PORT which fetches the assigned port number. For flask, python : port = int(os.environ.get('PORT', 5000)) This dynamically fetches port number and sets it. If not uses 5000. Solved the problem for me. If not there could be another issue but typically this is the fix.

Other possible error

The Heroku app need gunicorn to interface with your app. So, create a Profile without any extension and add the code as @nop33 has mentioned on the thread. Be sure to double check the name of your app and name mentioned in the Procfile. Because the Procfile gives Heroku the information to run your app

max-quirk commented 5 years ago

@PraveenAsh I'm having the same problem with a flask app. Where am I supposed to add that python code you mentioned? In my app.py file? If so, where exactly in the app.py file? Thanks

RaghunathVadlakonda commented 5 years ago

I'd be interested in knowing the solution for this. I build a node/Express app, using reactJS. when I deployed to Heroku, I got a similar issue. Can anyone explain to me how to solve this problem? screenshot 2019-03-04 at 1 11 37 pm

thenoelman commented 5 years ago

I'm having the same problem with a python/flask app. Runs great locally, but crashes when I attempt to deploy to Heroku. This is my first time attempting to use Heroku. Error messages pasted below from the logs. Any help would be really appreciated.

2019-03-07T03:27:00.387148+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=unjobbed.herokuapp.com request_id=3eb33c9e-c2ea-4219-9f92-73526be02d1b fwd="24.22.76.12" dyno= connect= service= status=503 bytes= protocol=https 2019-03-07T03:27:01.031500+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=unjobbed.herokuapp.com request_id=9c38b99c-e5f5-467b-8158-b2c431ceb248 fwd="24.22.76.12" dyno= connect= service= status=503 bytes= protocol=https

kcwoodfield commented 5 years ago

@thenoelman I'm having almost exactly the same issue. Have you resolved yours?

thenoelman commented 5 years ago

@kcwoodfield No, never figured it out.

pritamsgvu commented 5 years ago

@celikmustafa89

Where do i need to add this? in which file? log.Fatal(http.ListenAndServe(":" + os.Getenv("PORT"), router))

Varuas37 commented 5 years ago

@thenoelman Were you able to figure this out? I am having the same problem

jacobsteenhuysen commented 5 years ago

Nope :(

On Fri, May 17, 2019 at 03:39 Varuas37 notifications@github.com wrote:

@thenoelman https://github.com/thenoelman Were you able to figure this out? I am having the same problem

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/realpython/flask-boilerplate/issues/14?email_source=notifications&email_token=AEW2HP6VJTNXHZVARROUQHLPVZOJXA5CNFSM4BEZTEEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVUAAJQ#issuecomment-493355046, or mute the thread https://github.com/notifications/unsubscribe-auth/AEW2HP6LNIXSM32V2PZCWS3PVZOJXANCNFSM4BEZTEEA .

sherafghanasad commented 5 years ago

Hi guys, I am getting a similar error when I try using the deployed app from heroku. Can anyone help?

2019-05-23T00:32:35.185801+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/test?gender=2&age=5&education=5&party=12&session=abc1234&id=3029743" host=cryptic-badlands-39397.herokuapp.com request_id=92d85a20-5ede-45ae-9906-204d6372c897 fwd="34.211.243.55" dyno= connect= service= status=503 bytes= protocol=https
2019-05-23T00:32:35.568654+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/test?gender=2&age=5&education=5&party=12&session=abc1234&id=3029743" host=cryptic-badlands-39397.herokuapp.com request_id=d5d741be-c0bd-4dd5-8190-ac5739ddc82f fwd="34.211.243.55" dyno= connect= service= status=503 bytes= protocol=https
2019-05-23T00:32:35.899064+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/test?gender=2&age=5&education=5&party=12&session=abc1234&id=3029743" host=cryptic-badlands-39397.herokuapp.com request_id=2bcbbf7a-76a7-4ecc-9319-067b3e88a14e fwd="34.211.243.55" dyno= connect= service= status=503 bytes= protocol=https
tadakabooz9090 commented 4 years ago

I'm not sure if this applies to any of you but might help someone out. My Procfile was like this web gunicorn app:app but my requirements.txt did not include gunicorn as I had not been using it when testing it locally. Once I added it to my requirements everything was fine

IKrehan commented 4 years ago

I'm having the same problem with a flask project. Runs locally, but crashes when I deploy to Heroku.

Error: 2020-02-04T07:37:29.181357+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=criticancia.herokuapp.com request_id=13282857-17e5-4639-80ed-025d992e5058 fwd="189.40.102.107" dyno= connect= service= status=503 bytes= protocol=https 2020-02-04T07:37:29.683718+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=criticancia.herokuapp.com request_id=d34ac233-d2ba-4abb-b742-0918c9f56fe2 fwd="189.40.102.107" dyno= connect= service= status=503 bytes= protocol=https

hizclick commented 4 years ago

Having the same issue

datomnurdin commented 4 years ago

any solution?

DiogoFerrari commented 4 years ago

Same

Aakash-mistry commented 4 years ago

same error

IKrehan commented 4 years ago

In my case the problem was in the procfile. My project use multiple file strutucture so the procfile archive need to be like this "web: gunicorn Site:'create_app()". "Site" is the project folder and "create_app" is the function in init.py.

Hope it helps :)

victoriateo commented 4 years ago

Hi @IKrehan, could you elaborate more on how your multiple file structure looks like?

I have a multiple file structure too, which looks like below. In the root folder, there's app.py (the main file) and the pages folder which contains one.py and two.py. app.py will import one and two.

app.py pages one.py two.py

I am wondering if my mistake is in the procfile. Currently, my Procfile contains "web: gunicorn app:server --timeout 300". Please help me. Thanks.

Ayush23Dash commented 4 years ago

Hi I am trying to deploy a nodejs application that has Mongo Atlas as a cloud DB.I am having NPM err:missing start script error and H10 Heroku error. Any solutions please?

IKrehan commented 4 years ago

Hey, sorry for the delay to answer,

I think I expressed myself wrongly when I said "Multiple Files", I should said "Package". Sorry for this. You can know more about this here: https://explore-flask.readthedocs.io/en/latest/organizing.html Organizing your project — Explore Flask 1.0 documentationhttps://explore-flask.readthedocs.io/en/latest/organizing.html Organizing your project¶. Flask leaves the organization of your application up to you. This is one of the reasons I liked Flask as a beginner, but it does mean that you have to put some thought into how to structure your code. explore-flask.readthedocs.io

About you error, just br sure that in "web: gunicorn app:server --timeout 300" "server" is the variable that called Flask(). Your app.py should have this "server = Flask(name)"

Im not much experienced in Flask but I hope this helped. Fell free to ask me again and I will try to help.

Best regards.


De: victoriateo notifications@github.com Enviado: sábado, 11 de abril de 2020 19:42 Para: realpython/flask-boilerplate flask-boilerplate@noreply.github.com Cc: Irvig Krehan IrvigKrehan@Hotmail.com; Mention mention@noreply.github.com Assunto: Re: [realpython/flask-boilerplate] Deploying app on Heroku (code=H10 desc="App crashed") (#14)

Hi @IKrehanhttps://github.com/IKrehan, could you elaborate more on how your multiple file structure looks like?

I have a multiple file structure too, which looks like below. In the root folder, there's app.py (the main file) and the pages folder which contains one.py and two.py. app.py will import one and two.

app.py pages one.py two.py

I am wondering if my mistake is in the procfile. Currently, my Procfile contains "web: gunicorn app:server --timeout 300". Please help me. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/realpython/flask-boilerplate/issues/14#issuecomment-612499281, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJKMXIIDIMSOEVZ23FXDGRTRMDBZZANCNFSM4BEZTEEA.

VikrantAgrahari commented 4 years ago

In my case the problem was in the procfile. My project use multiple file strutucture so the procfile archive need to be like this "web: gunicorn Site:'create_app()". "Site" is the project folder and "create_app" is the function in init.py.

Hope it helps :)

What create_app() function do in init.py?

Pladque commented 4 years ago

I had same problem, and fixed it I did exacly like he said here: https://youtu.be/kBwhtEIXGII?t=535 problem were in Procfile

Herant commented 4 years ago

I had same problem, and fixed it I did exacly like he said here: https://youtu.be/kBwhtEIXGII?t=535 problem were in Procfile

That video shows bunch of other stuff.. that is far from "only" having issue in Procfile

Pladque commented 4 years ago

That video shows bunch of other stuff.. that is far from "only" having issue in Procfile . I share yt link with time (535 sec if it doest work) and I created Procfile step by step as a man on video said. Maby ur problem is in something else. I only shared my solution.

Ameerpappay commented 4 years ago

still facing this issue? any solutions?

salhi197 commented 4 years ago

image having the same issue ! any solution ?