Code Self Study Forum

Need help deploying my flask app to heroku

Hi everybody.
Hope everybody is doing good.
I have developed an App using flask. I need to deploy it. I am using Heroku. However, I keep getting the following error. Can you guys help me please? Thanks
Error:

2021-05-03T02:00:05.888078+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=beam02.herokuapp.com request_id=341b6a06-a37a-4fc6-8533-5dfafb0b0cf4 fwd="98.42.42.45" dyno= connect= service= status=503 bytes= protocol=https
2021-05-03T02:00:06.163591+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=beam02.herokuapp.com request_id=c555739b-9a09-4202-acbc-258910994c88 fwd="98.42.42.45" dyno= connect= service= status=503 bytes= protocol=https
1 Like

Is there any more information in the logs? (I think the command is: heroku logs)

My ProcFile is this: web: gunicorn app:StrWeb

heroku logs:

2021-05-03T04:08:43.953443+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-03T04:08:49.940317+00:00 heroku[web.1]: Starting process with command gunicorn app:StrWeb
2021-05-03T04:08:53.234677+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-05-03T04:08:53.235468+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [4] [INFO] Listening at: http://0.0.0.0:6529 (4)
2021-05-03T04:08:53.235623+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [4] [INFO] Using worker: sync
2021-05-03T04:08:53.240313+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [7] [INFO] Booting worker with pid: 7
2021-05-03T04:08:53.246534+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [7] [ERROR] Exception in worker process
2021-05-03T04:08:53.246537+00:00 app[web.1]: Traceback (most recent call last):
2021-05-03T04:08:53.246537+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py”, line 589, in spawn_worker
2021-05-03T04:08:53.246538+00:00 app[web.1]: worker.init_process()
2021-05-03T04:08:53.246538+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py”, line 134, in init_process
2021-05-03T04:08:53.246539+00:00 app[web.1]: self.load_wsgi()
2021-05-03T04:08:53.246539+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py”, line 146, in load_wsgi
2021-05-03T04:08:53.246539+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-05-03T04:08:53.246540+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py”, line 67, in wsgi
2021-05-03T04:08:53.246540+00:00 app[web.1]: self.callable = self.load()
2021-05-03T04:08:53.246541+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py”, line 58, in load
2021-05-03T04:08:53.246541+00:00 app[web.1]: return self.load_wsgiapp()
2021-05-03T04:08:53.246541+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp
2021-05-03T04:08:53.246542+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-05-03T04:08:53.246542+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py”, line 359, in import_app
2021-05-03T04:08:53.246543+00:00 app[web.1]: mod = importlib.import_module(module)
2021-05-03T04:08:53.246543+00:00 app[web.1]: File β€œ/app/.heroku/python/lib/python3.9/importlib/init.py”, line 127, in import_module
2021-05-03T04:08:53.246544+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-05-03T04:08:53.246544+00:00 app[web.1]: File β€œβ€, line 1030, in _gcd_import
2021-05-03T04:08:53.246544+00:00 app[web.1]: File β€œβ€, line 1007, in _find_and_load
2021-05-03T04:08:53.246545+00:00 app[web.1]: File β€œβ€, line 984, in _find_and_load_unlocked
2021-05-03T04:08:53.246545+00:00 app[web.1]: ModuleNotFoundError: No module named β€˜app’
2021-05-03T04:08:53.246650+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-05-03T04:08:53.286348+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [4] [INFO] Shutting down: Master
2021-05-03T04:08:53.286411+00:00 app[web.1]: [2021-05-03 04:08:53 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-05-03T04:08:53.364632+00:00 heroku[web.1]: Process exited with status 3
2021-05-03T04:08:53.462338+00:00 heroku[web.1]: State changed from starting to crashed

Does it run on your computer? Is the source code on Github?

What is the file name of the main Flask file? Is it named app.py?

(I’m looking at this part: ModuleNotFoundError: No module named β€˜app’)

Yes, It runs very well locally. After deployment , I receive Application error page.

Yes, I have app.py and also init.py.
I can email you the source code. Unfortunately, I don’t have it on GitHub. Thanks Josh.

1 Like