flask-boilerplate: Deploying app on Heroku (code=H10 desc="App crashed")
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
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 6
- Comments: 73 (1 by maintainers)
Commits related to this issue
- modify procfile for heroku https://github.com/realpython/flask-boilerplate/issues/14 — committed to kacasey8/option_wheel_tracker by kacasey8 4 years ago
I figured out that I have to use
web: gunicorn app:app --log-file=-in theProcfile.where? in Procfile?
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?
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.PORTwhich 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
I found two possible solutions:
web: gunicorn <application-name>.wsgi --log-file -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:
What you can do is, getting the runtime port of heroku.
In short, just use the following code:
Heyy, Check your procfile and make sure all your dependencies are well set.
On Fri, 12 Nov 2021, 23:38 Matt, @.***> wrote:
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
I’m not sure if this applies to any of you but might help someone out. My Procfile was like this
web gunicorn app:appbut 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 fineAnother solution:
Check if your application has ‘gunicorn’ installed with
pip freeze, if not, run the commandpip install gunicorn.After that, run
pip freeze > requirements.txtWith that it will create a file with the current requirements of your application, note that ‘gunicorn’ will be in it.
@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