0
votes

I am attempting to deploy a simple Flask app through Heroku, yet I am receiving an H10 Error. I am manually deploying with Github on the Heroku website.

I have tried using to commands 'heroku restart', heroku ps:scale web=1, pip freeze > requirements.txt, and dynos and changing my Procfile to include -b :$PORT, changing the PORT in my flask python file to app.run(debug=True, port=33507, port = int(os.environ.get('PORT', 5000)) and app.run(host='0.0.0.0', port=port), changing my repo to match https://github.com/zachwill/flask_heroku, and adding gunicorn and gevent to the requirements.txt.

App

port = int(os.environ.get('PORT', 5000))
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=port)

Procfile

web: gunicorn -b :$PORT flaskapp:app

requirements.txt

gunicorn
gevent

Error

2019-07-08T19:29:05.872509+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-08T19:29:05.497279+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-07-08T19:29:05.498369+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Listening at: http://0.0.0.0:39703 (4)
2019-07-08T19:29:05.498552+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Using worker: sync
2019-07-08T19:29:05.505408+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [10] [INFO] Booting worker with pid: 10
2019-07-08T19:29:05.539492+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [10] [ERROR] Exception in worker process
2019-07-08T19:29:05.539497+00:00 app[web.1]: Traceback (most recent call last):
2019-07-08T19:29:05.539499+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-07-08T19:29:05.539501+00:00 app[web.1]: worker.init_process()
2019-07-08T19:29:05.539503+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-07-08T19:29:05.539507+00:00 app[web.1]: self.load_wsgi()
2019-07-08T19:29:05.539510+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-07-08T19:29:05.539512+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-07-08T19:29:05.539514+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-08T19:29:05.539516+00:00 app[web.1]: self.callable = self.load()
2019-07-08T19:29:05.539518+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-08T19:29:05.539520+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-08T19:29:05.539522+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-08T19:29:05.539524+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-08T19:29:05.539526+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-08T19:29:05.539528+00:00 app[web.1]: __import__(module)
2019-07-08T19:29:05.539530+00:00 app[web.1]: File "/app/flaskapp.py", line 4, in <module>
2019-07-08T19:29:05.539532+00:00 app[web.1]: from pml import app
2019-07-08T19:29:05.539577+00:00 app[web.1]: ModuleNotFoundError: No module named 'pml'
2019-07-08T19:29:05.539825+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-07-08T19:29:05.555645+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [11] [INFO] Booting worker with pid: 11
2019-07-08T19:29:05.574207+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [11] [ERROR] Exception in worker process
2019-07-08T19:29:05.574212+00:00 app[web.1]: Traceback (most recent call last):
2019-07-08T19:29:05.574214+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-07-08T19:29:05.574216+00:00 app[web.1]: worker.init_process()
2019-07-08T19:29:05.574218+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-07-08T19:29:05.574220+00:00 app[web.1]: self.load_wsgi()
2019-07-08T19:29:05.574222+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-07-08T19:29:05.574224+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-07-08T19:29:05.574226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-08T19:29:05.574228+00:00 app[web.1]: self.callable = self.load()
2019-07-08T19:29:05.574230+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-08T19:29:05.574232+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-08T19:29:05.574234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-08T19:29:05.574236+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-08T19:29:05.574238+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-08T19:29:05.574240+00:00 app[web.1]: __import__(module)
2019-07-08T19:29:05.574242+00:00 app[web.1]: File "/app/flaskapp.py", line 4, in <module>
2019-07-08T19:29:05.574244+00:00 app[web.1]: from pml import app
2019-07-08T19:29:05.574246+00:00 app[web.1]: ModuleNotFoundError: No module named 'pml'
2019-07-08T19:29:05.574494+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [11] [INFO] Worker exiting (pid: 11)
2019-07-08T19:29:05.682720+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Shutting down: Master
2019-07-08T19:29:05.682883+00:00 app[web.1]: [2019-07-08 19:29:05 +0000] [4] [INFO] Reason: Worker failed to boot.
2019-07-08T19:29:05.849393+00:00 heroku[web.1]: Process exited with status 3
2019-07-08T19:35:15.978510+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=randommovieroulette.herokuapp.com request_id=4e2ad446-cd8a-4136-9875-f94381259b5e fwd="173.71.157.150" dyno= connect= service= status=503 bytes= protocol=https
2019-07-08T19:35:18.311763+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=randommovieroulette.herokuapp.com request_id=154f2f1f-afeb-4765-8e05-1f908fe2d0f4 fwd="173.71.157.150" dyno= connect= service= status=503 bytes= protocol=https

The app is 'deploying', but something is wrong with the server end. Making a runtime.txt with my current python version stops the app from deploying. Should I make this a different version, then? I'm a newbie, so my deep apologies if I am making just a simple error.

1
You're focused on the port, but that's not the issue. Your output says "ModuleNotFoundError: No module named 'pml'". Do you intend to depend on this, or is pml something you wrote yourself?Chris
SOLVED! The problem was the requirements.txt it didn't have all of the packages I imported in it. For some reason, it only need some of the packages, not all of the them. THANK you so much!bwhte4
I'm glad you got this working. Please consider answering your own question.Chris

1 Answers

0
votes

The requirements.txt did not include flask_wtf, bs4, requests, or app, all of which were imported in my flaskapp.py file. This file only included gunicorn and gevent previously.