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.54k stars 536 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

victoriateo commented 4 years ago

My data file was too big (~1GB) and I reduced it significantly by more than half, and it eventually worked. I'm guessing there was this error because pd.read_csv (pandas library's read_csv function) takes very long to read the big file, hence resulting in the crash.

You can also help to debug by adding print statements throughout your main file (app.py in my case) and then looking at the heroku log files to see which statements managed to be printed/ not printed, to figure out at which line does the crash happen.

Pladque commented 4 years ago

image having the same issue ! any solution ?

Have u tried my solution?

devcoder007 commented 4 years ago

I found two possible solutions: 1) try adding "gunicorn" to your requirements.txt file. 2) make your Procfile like this: web: gunicorn <application-name>.wsgi --log-file -

IshanSethi9 commented 4 years ago

2020-08-17T08:02:40.753076+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=musical-instrument.herokuapp.com request_id=0ccaa6ab-61f9-436c-81c8-e950f38581b5 fwd="106.198.170.193" dyno= connect= service= status=503 bytes= protocol=https 2020-08-17T08:02:42.014385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=musical-instrument.herokuapp.com request_id=0cc841b6-7996-4d07-8b84-ddc553973b59 fwd="106.198.233.145" dyno= connect= service= status=503 bytes= protocol=https

I'm still facing this problem, if somebody has solved this then please help me out.

Pladque commented 4 years ago

2020-08-17T08:02:40.753076+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=musical-instrument.herokuapp.com request_id=0ccaa6ab-61f9-436c-81c8-e950f38581b5 fwd="106.198.170.193" dyno= connect= service= status=503 bytes= protocol=https 2020-08-17T08:02:42.014385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=musical-instrument.herokuapp.com request_id=0cc841b6-7996-4d07-8b84-ddc553973b59 fwd="106.198.233.145" dyno= connect= service= status=503 bytes= protocol=https

I'm still facing this problem, if somebody has solved this then please help me out.

Can you show me which tutorial u used?

IshanSethi9 commented 4 years ago

https://github.com/IshanSethi9/Musical-instruments Please Check the repo here.

Pladque commented 4 years ago

https://github.com/IshanSethi9/Musical-instruments Please Check the repo here.

In ProcFile im not sure if you can us spaces in name of app I mean: web: gunicorn Musical Instruments.wsgi --log-file - ->try to rename app to somthing without white spaces. Make sure u made migrations and migreted it. If it doesnt help, you should check if your project isnt too heavy for free heroku app (i mean music take a lot of memory). And last, i couldnt find it, but I remember I used something in console with '$' at the begin and it helped. It was something like entering a special mode, that i could makemigrations better or something.

IshanSethi9 commented 4 years ago

I tried it without space,|web: gunicorn MusicalInstruments.wsgi --log-file -|, but still it doesn't work. The project compiled with 222.1 mb of space out of max possible 500 mb so i guess the project isnt too heavy for the software

IshanSethi9 commented 4 years ago

image Does heroku support computer vision? If I check the first line, it is not able to import the cv2 library that is used for computer vision. Issue Resolved.

bawantha commented 4 years ago

SAME

bawantha commented 4 years ago

image Does heroku support computer vision? If I check the first line, it is not able to import the cv2 library that is used for computer vision. Issue Resolved.

did you find any soltions

salhi197 commented 4 years ago

this error is due to the miss of the .env file , check again your .env file ,and change syntaxe of used port , it will work ,

Le dim. 4 oct. 2020 à 19:06, Bawantha Mihiran Rajapaksha < notifications@github.com> a écrit :

SAME

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/realpython/flask-boilerplate/issues/14#issuecomment-703293150, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJB2EWUIVZSJCHAK2YXF3LDSJC2TZANCNFSM4BEZTEEA .

MarounMaroun commented 4 years ago

I was using Python 3.8.6 while the Heroku server was running an older version. Since I'm using features that weren't available in the older version, I got the above error.

Try to update the Python's version on the dyno:

kalpthakkar commented 4 years ago

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:

Step 1: Run this command

npm install serve --s

Replace old scripts with this one into the package.json file

"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"
}

*Note: There might come 1 vulnerability along with this, but to fix that, simply run

npm audit fix --force

And not you are ready to see the magic come true ;)

git add .
git commit -m "deploy"
git push heroku master
heroku open

This was the most frustrating problem... But now you have the key I am sure it will work like magic :) Give it a try

AdarshPan commented 3 years ago

Having the same problem with Django and Python=3.6.10

my procfile inlcudes: web: gunicorn .wsgi

Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved.

C:\windows\system32>heroku logs --tail » Error: Missing required flag: » -a, --app APP app to run command against » See more help with --help

C:\windows\system32>heroku logs --tail -a healtech 2021-01-11T15:02:05.933848+00:00 app[web.1]: [2021-01-11 15:02:05 +0000] [11] [I NFO] Worker exiting (pid: 11) 2021-01-11T15:02:05.933853+00:00 app[web.1]: [2021-01-11 15:02:05 +0000] [10] [E RROR] Exception in worker process 2021-01-11T15:02:05.933854+00:00 app[web.1]: Traceback (most recent call last): 2021-01-11T15:02:05.933855+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2021-01-11T15:02:05.933855+00:00 app[web.1]: worker.init_process() 2021-01-11T15:02:05.933855+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process 2021-01-11T15:02:05.933856+00:00 app[web.1]: self.load_wsgi() 2021-01-11T15:02:05.933856+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi 2021-01-11T15:02:05.933856+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-01-11T15:02:05.933857+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-01-11T15:02:05.933857+00:00 app[web.1]: self.callable = self.load() 2021-01-11T15:02:05.933857+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load 2021-01-11T15:02:05.933858+00:00 app[web.1]: return self.load_wsgiapp() 2021-01-11T15:02:05.933858+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp 2021-01-11T15:02:05.933859+00:00 app[web.1]: return util.import_app(self.app_uri ) 2021-01-11T15:02:05.933859+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/util.py", line 358, in import_app 2021-01-11T15:02:05.933859+00:00 app[web.1]: mod = importlib.import_module(modul e) 2021-01-11T15:02:05.933860+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/importlib/init.py", line 126, in import_module 2021-01-11T15:02:05.933860+00:00 app[web.1]: return _bootstrap._gcd_import(name[ level:], package, level) 2021-01-11T15:02:05.933861+00:00 app[web.1]: File " ", line 994, in _gcd_import 2021-01-11T15:02:05.933861+00:00 app[web.1]: File " ", line 971, in _find_and_load 2021-01-11T15:02:05.933861+00:00 app[web.1]: File " ", line 941, in _find_and_load_unlocked 2021-01-11T15:02:05.933862+00:00 app[web.1]: File " ", line 219, in _call_with_frames_removed 2021-01-11T15:02:05.933862+00:00 app[web.1]: File " ", line 994, in _gcd_import 2021-01-11T15:02:05.933863+00:00 app[web.1]: File " ", line 971, in _find_and_load 2021-01-11T15:02:05.933863+00:00 app[web.1]: File " ", line 953, in _find_and_load_unlocked 2021-01-11T15:02:05.933913+00:00 app[web.1]: ModuleNotFoundError: No module name d 'HealTech' 2021-01-11T15:02:05.941551+00:00 app[web.1]: [2021-01-11 15:02:05 +0000] [10] [I NFO] Worker exiting (pid: 10) 2021-01-11T15:02:06.156671+00:00 app[web.1]: [2021-01-11 15:02:06 +0000] [4] [IN FO] Shutting down: Master 2021-01-11T15:02:06.157400+00:00 app[web.1]: [2021-01-11 15:02:06 +0000] [4] [IN FO] Reason: Worker failed to boot. 2021-01-11T15:02:06.354673+00:00 heroku[web.1]: Process exited with status 3 2021-01-11T15:02:06.404737+00:00 heroku[web.1]: State changed from up to crashed

2021-01-11T15:02:06.408675+00:00 heroku[web.1]: State changed from crashed to st arting 2021-01-11T15:02:49.936312+00:00 heroku[web.1]: Starting process with command g unicorn HealTech.wsgi --log-file - 2021-01-11T15:02:50.000000+00:00 app[api]: Build succeeded 2021-01-11T15:02:54.195478+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [4] [IN FO] Starting gunicorn 20.0.4 2021-01-11T15:02:54.196657+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [4] [IN FO] Listening at: http://0.0.0.0:36107 (4) 2021-01-11T15:02:54.201883+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [4] [IN FO] Using worker: sync 2021-01-11T15:02:54.217181+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [10] [I NFO] Booting worker with pid: 10 2021-01-11T15:02:54.234018+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [10] [E RROR] Exception in worker process 2021-01-11T15:02:54.234035+00:00 app[web.1]: Traceback (most recent call last): 2021-01-11T15:02:54.234040+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2021-01-11T15:02:54.234045+00:00 app[web.1]: worker.init_process() 2021-01-11T15:02:54.234045+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process 2021-01-11T15:02:54.234046+00:00 app[web.1]: self.load_wsgi() 2021-01-11T15:02:54.234046+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi 2021-01-11T15:02:54.234046+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-01-11T15:02:54.234051+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-01-11T15:02:54.234051+00:00 app[web.1]: self.callable = self.load() 2021-01-11T15:02:54.234051+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load 2021-01-11T15:02:54.234052+00:00 app[web.1]: return self.load_wsgiapp() 2021-01-11T15:02:54.234052+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp 2021-01-11T15:02:54.234052+00:00 app[web.1]: return util.import_app(self.app_uri ) 2021-01-11T15:02:54.234053+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/util.py", line 358, in import_app 2021-01-11T15:02:54.234053+00:00 app[web.1]: mod = importlib.import_module(modul e) 2021-01-11T15:02:54.234053+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/importlib/init.py", line 126, in import_module 2021-01-11T15:02:54.234054+00:00 app[web.1]: return _bootstrap._gcd_import(name[ level:], package, level) 2021-01-11T15:02:54.234054+00:00 app[web.1]: File " ", line 994, in _gcd_import 2021-01-11T15:02:54.234055+00:00 app[web.1]: File " ", line 971, in _find_and_load 2021-01-11T15:02:54.234055+00:00 app[web.1]: File " ", line 941, in _find_and_load_unlocked 2021-01-11T15:02:54.234056+00:00 app[web.1]: File " ", line 219, in _call_with_frames_removed 2021-01-11T15:02:54.234056+00:00 app[web.1]: File " ", line 994, in _gcd_import 2021-01-11T15:02:54.234056+00:00 app[web.1]: File " ", line 971, in _find_and_load 2021-01-11T15:02:54.234057+00:00 app[web.1]: File " ", line 953, in _find_and_load_unlocked 2021-01-11T15:02:54.236531+00:00 app[web.1]: ModuleNotFoundError: No module name d 'HealTech' 2021-01-11T15:02:54.236949+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [10] [I NFO] Worker exiting (pid: 10) 2021-01-11T15:02:54.298315+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [11] [I NFO] Booting worker with pid: 11 2021-01-11T15:02:54.308096+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [11] [E RROR] Exception in worker process 2021-01-11T15:02:54.308099+00:00 app[web.1]: Traceback (most recent call last): 2021-01-11T15:02:54.308100+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2021-01-11T15:02:54.308100+00:00 app[web.1]: worker.init_process() 2021-01-11T15:02:54.308101+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process 2021-01-11T15:02:54.308101+00:00 app[web.1]: self.load_wsgi() 2021-01-11T15:02:54.308102+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi 2021-01-11T15:02:54.308102+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-01-11T15:02:54.308103+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-01-11T15:02:54.308103+00:00 app[web.1]: self.callable = self.load() 2021-01-11T15:02:54.308104+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load 2021-01-11T15:02:54.308104+00:00 app[web.1]: return self.load_wsgiapp() 2021-01-11T15:02:54.308105+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp 2021-01-11T15:02:54.308105+00:00 app[web.1]: return util.import_app(self.app_uri ) 2021-01-11T15:02:54.308105+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/site-packages/gunicorn/util.py", line 358, in import_app 2021-01-11T15:02:54.308106+00:00 app[web.1]: mod = importlib.import_module(modul e) 2021-01-11T15:02:54.308106+00:00 app[web.1]: File "/app/.heroku/python/lib/pytho n3.6/importlib/init.py", line 126, in import_module 2021-01-11T15:02:54.308106+00:00 app[web.1]: return _bootstrap._gcd_import(name[ level:], package, level) 2021-01-11T15:02:54.308107+00:00 app[web.1]: File " ", line 994, in _gcd_import 2021-01-11T15:02:54.308107+00:00 app[web.1]: File " ", line 971, in _find_and_load 2021-01-11T15:02:54.308108+00:00 app[web.1]: File " ", line 941, in _find_and_load_unlocked 2021-01-11T15:02:54.308108+00:00 app[web.1]: File " ", line 219, in _call_with_frames_removed 2021-01-11T15:02:54.308108+00:00 app[web.1]: File " ", line 994, in _gcd_import 2021-01-11T15:02:54.308109+00:00 app[web.1]: File " ", line 971, in _find_and_load 2021-01-11T15:02:54.308109+00:00 app[web.1]: File " ", line 953, in _find_and_load_unlocked 2021-01-11T15:02:54.308117+00:00 app[web.1]: ModuleNotFoundError: No module name d 'HealTech' 2021-01-11T15:02:54.308851+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [11] [I NFO] Worker exiting (pid: 11) 2021-01-11T15:02:54.469000+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [4] [IN FO] Shutting down: Master 2021-01-11T15:02:54.469216+00:00 app[web.1]: [2021-01-11 15:02:54 +0000] [4] [IN FO] Reason: Worker failed to boot. 2021-01-11T15:02:54.621000+00:00 heroku[web.1]: Process exited with status 3 2021-01-11T15:02:54.699115+00:00 heroku[web.1]: State changed from starting to c rashed 2021-01-11T15:02:59.805850+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/" host=healtech.herokuapp.com request_id=6d60bf79-9e4d-4 786-9ae7-054c3aef4473 fwd="157.40.20.59" dyno= connect= service= status=503 byte s= protocol=https 2021-01-11T15:03:01.374208+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/favicon.ico" host=healtech.herokuapp.com request_id=84f9 9215-a069-4666-a403-0481d927b106 fwd="157.40.20.59" dyno= connect= service= stat us=503 bytes= protocol=https

IrfanDarood commented 3 years ago

In the Procfile,

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

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

this worked for me. Thanks alot!

felip3costa commented 3 years ago

Another solution:

Check if your application has 'gunicorn' installed with pip freeze, if not, run the command pip install gunicorn.

After that, run pip freeze > requirements.txt

With that it will create a file with the current requirements of your application, note that 'gunicorn' will be in it.

manelalayet19 commented 3 years ago

i'm having the same problem, i tried everything my Procfile is web: gunicorn index:server --preload --timeout300

FartPrincess69 commented 3 years ago

I'm having the same issue, I tried all the suggestions in this thread and more from googling the error, but nothing worked :(

matias-cavalcante commented 2 years ago

Hi, hope this is still usefull and on topic, but I have been struggling also with this app crashed issue using Flask to deploy my API. I am also new to Heroku so I had not much clue of what I was doing. But check well the result of the "heroku logs --tail". What happened in my case was that there was nothing wrong with ports, Procfile, requirements or that kind of things. The code I had to deal with the data the API was handling WAS WRONG. So that is why it was crushing, once fixed everything worked fine.

manelalayet19 commented 2 years ago

Heyy, Check your procfile and make sure all your dependencies are well set.

On Fri, 12 Nov 2021, 23:38 Matt, @.***> wrote:

Hi, hope this is still usefull and on topic, but I have been struggling also with this app crashed issue using Flask to deploy my API. I am also new to Heroku so I had not much clue of what I was doing. But check well the result of the "heroku logs --tail". What happened in my case was that there was nothing wrong with ports, Procfile, requirements or that kind of things. The code I had to deal with the data the API was handling WAS WRONG. So that is why it was crushing, once fixed everything worked fine.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/realpython/flask-boilerplate/issues/14#issuecomment-967706500, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOIAFHY7RSIHQ7SWQVFG5R3ULWJOXANCNFSM4BEZTEEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

opeeyum commented 2 years ago

Make sure you not uploading the virtual environment directory in the remote repo.

GaryHDSL commented 2 years ago

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

change your Procfile to encoding to UTF-8 very sure answer