0

I am trying to deploy my Django app to Heroku. I am following all the steps mentioned on Heroku dev center https://devcenter.heroku.com/articles/django-app-configuration. The app deploys successfully but when I run heroku open or manually visit the link it shows

Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail

My Logs:

2021-07-13T18:26:37.515968+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-07-13T18:26:37.515969+00:00 app[web.1]: self.callable = self.load() 2021-07-13T18:26:37.515969+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load 2021-07-13T18:26:37.515970+00:00 app[web.1]: return self.load_wsgiapp() 2021-07-13T18:26:37.515970+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp 2021-07-13T18:26:37.515970+00:00 app[web.1]: return util.import_app(self.app_uri) 2021-07-13T18:26:37.515970+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app 2021-07-13T18:26:37.515971+00:00 app[web.1]: mod = importlib.import_module(module) 2021-07-13T18:26:37.515971+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module 2021-07-13T18:26:37.515972+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2021-07-13T18:26:37.515972+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 2021-07-13T18:26:37.515973+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 2021-07-13T18:26:37.515973+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked 2021-07-13T18:26:37.515973+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed 2021-07-13T18:26:37.515974+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 2021-07-13T18:26:37.515974+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 2021-07-13T18:26:37.515974+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked 2021-07-13T18:26:37.515975+00:00 app[web.1]: ModuleNotFoundError: No module named 'myproject' 2021-07-13T18:26:37.516146+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [7] [INFO] Worker exiting (pid: 7) 2021-07-13T18:26:37.520489+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [8] [INFO] Booting worker with pid: 8 2021-07-13T18:26:37.527381+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [8] [ERROR] Exception in worker process 2021-07-13T18:26:37.527382+00:00 app[web.1]: Traceback (most recent call last): 2021-07-13T18:26:37.527383+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker 2021-07-13T18:26:37.527383+00:00 app[web.1]: worker.init_process() 2021-07-13T18:26:37.527384+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process 2021-07-13T18:26:37.527384+00:00 app[web.1]: self.load_wsgi() 2021-07-13T18:26:37.527385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi 2021-07-13T18:26:37.527387+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-07-13T18:26:37.527388+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-07-13T18:26:37.527388+00:00 app[web.1]: self.callable = self.load() 2021-07-13T18:26:37.527389+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load 2021-07-13T18:26:37.527389+00:00 app[web.1]: return self.load_wsgiapp() 2021-07-13T18:26:37.527389+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp 2021-07-13T18:26:37.527390+00:00 app[web.1]: return util.import_app(self.app_uri) 2021-07-13T18:26:37.527390+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app 2021-07-13T18:26:37.527391+00:00 app[web.1]: mod = importlib.import_module(module) 2021-07-13T18:26:37.527391+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module 2021-07-13T18:26:37.527392+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2021-07-13T18:26:37.527392+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 2021-07-13T18:26:37.527392+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 2021-07-13T18:26:37.527393+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked 2021-07-13T18:26:37.527393+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed 2021-07-13T18:26:37.527394+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 2021-07-13T18:26:37.527394+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 2021-07-13T18:26:37.527394+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked 2021-07-13T18:26:37.527395+00:00 app[web.1]: ModuleNotFoundError: No module named 'myproject' 2021-07-13T18:26:37.527519+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [8] [INFO] Worker exiting (pid: 8) 2021-07-13T18:26:37.575136+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [4] [WARNING] Worker with pid 7 was terminated due to signal 15 2021-07-13T18:26:37.677918+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [4] [INFO] Shutting down: Master 2021-07-13T18:26:37.678111+00:00 app[web.1]: [2021-07-13 18:26:37 +0000] [4] [INFO] Reason: Worker failed to boot. 2021-07-13T18:26:37.781026+00:00 heroku[web.1]: Process exited with status 3 2021-07-13T18:26:37.959596+00:00 heroku[web.1]: State changed from starting to crashed 2021-07-13T18:26:37.964944+00:00 heroku[web.1]: State changed from crashed to starting 2021-07-13T18:26:53.000000+00:00 app[api]: Build succeeded 2021-07-13T18:26:55.063317+00:00 heroku[web.1]: Starting process with command `gunicorn myproject.wsgi` 2021-07-13T18:26:59.003109+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [4] [INFO] Starting gunicorn 20.1.0 2021-07-13T18:26:59.003975+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [4] [INFO] Listening at: http://0.0.0.0:50049 (4) 2021-07-13T18:26:59.004155+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [4] [INFO] Using worker: sync 2021-07-13T18:26:59.013689+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [7] [INFO] Booting worker with pid: 7 2021-07-13T18:26:59.020640+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [7] [ERROR] Exception in worker process 2021-07-13T18:26:59.020665+00:00 app[web.1]: Traceback (most recent call last): 2021-07-13T18:26:59.020672+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker 2021-07-13T18:26:59.020677+00:00 app[web.1]: worker.init_process() 2021-07-13T18:26:59.020678+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process 2021-07-13T18:26:59.020678+00:00 app[web.1]: self.load_wsgi() 2021-07-13T18:26:59.020679+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi 2021-07-13T18:26:59.020679+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2021-07-13T18:26:59.020684+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi 2021-07-13T18:26:59.020685+00:00 app[web.1]: self.callable = self.load() 2021-07-13T18:26:59.020685+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load 2021-07-13T18:26:59.020686+00:00 app[web.1]: return self.load_wsgiapp() 2021-07-13T18:26:59.020686+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp 2021-07-13T18:26:59.020686+00:00 app[web.1]: return util.import_app(self.app_uri) 2021-07-13T18:26:59.020687+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app 2021-07-13T18:26:59.020687+00:00 app[web.1]: mod = importlib.import_module(module) 2021-07-13T18:26:59.020687+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module 2021-07-13T18:26:59.020688+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2021-07-13T18:26:59.020688+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 2021-07-13T18:26:59.020689+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 2021-07-13T18:26:59.020689+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked 2021-07-13T18:26:59.020690+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed 2021-07-13T18:26:59.020690+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import 2021-07-13T18:26:59.020691+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load 2021-07-13T18:26:59.020691+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked 2021-07-13T18:26:59.020692+00:00 app[web.1]: ModuleNotFoundError: No module named 'myproject' 2021-07-13T18:26:59.020997+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [7] [INFO] Worker exiting (pid: 7) 2021-07-13T18:26:59.089336+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [4] [INFO] Shutting down: Master 2021-07-13T18:26:59.089511+00:00 app[web.1]: [2021-07-13 18:26:59 +0000] [4] [INFO] Reason: Worker failed to boot. 2021-07-13T18:26:59.214561+00:00 heroku[web.1]: Process exited with status 3 2021-07-13T18:26:59.325816+00:00 heroku[web.1]: State changed from starting to crashed 2021-07-13T18:27:01.234730+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=heyady.herokuapp.com request_id=a7547546-fb0f-4a00-83ea-619e7128aef1 fwd="169.149.36.45" dyno= connect= service= status=503 bytes= protocol=https 2021-07-13T18:27:01.959325+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=heyady.herokuapp.com request_id=8d35e215-091f-432f-abf1-1a3dae52be5b fwd="169.149.36.45" dyno= connect= service= status=503 bytes= protocol=https 2021-07-13T18:28:08.924235+00:00 app[api]: Starting process with command `python manage.py migrate` by user [email protected] 2021-07-13T18:28:21.919810+00:00 heroku[run.5856]: State changed from starting to up 7a-acd0aab16891 fwd="169.149.22.37" dyno= connect= service= status=503 bytes= protocol=https 2021-07-13T18:28:36.667998+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=heyady.herokuapp.com request_id=2896e5e2-150f-4d77-a0c2-ecf77ce4e5a2 fwd="169.149.22.37" dyno= connect= service= status=503 bytes= protocol=https 
4
  • Hi Ady! Log is showing that the module "my_project" was not found. Some place on your code importing or referencing "my_project" and it not be installed. Check if "my_project" is a name of your app and if is listed on 'INSTALLED_APPS' on settings.py Commented Jul 13, 2021 at 19:27
  • Hey Marcello! Thanks for replying. I did notice that error but i couldn't find where this module is. I was working on a different project before where I created a virtualenv by name myproject. I copied some template code from there but i can't find where I'm referencing the same in this app. I checked my installed_apps and it's not there. Commented Jul 14, 2021 at 4:47
  • A tip is (in your IDE, I use Visual Studio) you search for "myproject " (without quotes) in root dir of your project, will show all files that has "my_project" in code. Maybe is easier to find. Because some where is referencing to "myproject". Commented Jul 14, 2021 at 15:19
  • @MarcelloBastos Yes, I did it the same way, found out my Proctile was referencing it. Appreciate your help. Thank you Commented Jul 14, 2021 at 15:28

1 Answer 1

1

So after a lot of research and reading the Django docs, Heroku docs, StackOverflow articles I found that I was doing it wrong all the time and because I read similar articles where people have the same problem. Maybe this is going to help you:

  1. The Procfile has no extensions.
  2. You should be deploying through a virtual environment
  3. the Procfile script is important and you need to add web: gunicorn myproject.wsgi where myproject is to be replaced by the name of your project.
  4. Make sure the Procfile is within your root directory and not inside a project subfolder.
Sign up to request clarification or add additional context in comments.

1 Comment

So the error was the reference to "myproject" in somewhere in code. Happy to help you Ady!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.