1

I'm trying to deploy my Django project on Heroku, but something is going wrong, and I'm not able to found out what is happening, and what to do in order to solve this. I read in other posts that the problem may be something related with Gunicorn, but I can't solve it.

(env) ignacio@ignacio:~/atletico$ heroku logs
2018-03-15T18:04:33.770218+00:00 app[web.1]: [2018-03-15 18:04:33 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-03-15T18:04:47.082000+00:00 heroku[web.1]: Starting process with command `gunicorn mysite.wsgi --log-file -`
2018-03-15T18:04:49.411412+00:00 heroku[web.1]: Process exited with status 3
2018-03-15T18:04:49.139027+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-03-15T18:04:49.139593+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Listening at: http://0.0.0.0:25381 (4)
2018-03-15T18:04:49.139786+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Using worker: sync
2018-03-15T18:04:49.149373+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [8] [ERROR] Exception in worker process
2018-03-15T18:04:49.149376+00:00 app[web.1]: Traceback (most recent call last):
2018-03-15T18:04:49.149391+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-03-15T18:04:49.149394+00:00 app[web.1]:     worker.init_process()
2018-03-15T18:04:49.143828+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [8] [INFO] Booting worker with pid: 8
2018-03-15T18:04:49.149396+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-03-15T18:04:49.149398+00:00 app[web.1]:     self.load_wsgi()
2018-03-15T18:04:49.149400+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-03-15T18:04:49.149401+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-03-15T18:04:49.149408+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-03-15T18:04:49.149411+00:00 app[web.1]:     self.callable = self.load()
2018-03-15T18:04:49.149413+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-03-15T18:04:49.149416+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-03-15T18:04:49.149418+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-03-15T18:04:49.149414+00:00 app[web.1]:     return self.load_wsgiapp()
2018-03-15T18:04:49.149422+00:00 app[web.1]:     __import__(module)
2018-03-15T18:04:49.149420+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-03-15T18:04:49.149513+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-03-15T18:04:49.154811+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [9] [INFO] Booting worker with pid: 9
2018-03-15T18:04:49.149424+00:00 app[web.1]: ModuleNotFoundError: No module named 'mysite.wsgi'
2018-03-15T18:04:49.163852+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [9] [ERROR] Exception in worker process
2018-03-15T18:04:49.163856+00:00 app[web.1]: Traceback (most recent call last):
2018-03-15T18:04:49.163860+00:00 app[web.1]:     worker.init_process()
2018-03-15T18:04:49.163858+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-03-15T18:04:49.163862+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-03-15T18:04:49.163863+00:00 app[web.1]:     self.load_wsgi()
2018-03-15T18:04:49.163865+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-03-15T18:04:49.163867+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-03-15T18:04:49.163869+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-03-15T18:04:49.163871+00:00 app[web.1]:     self.callable = self.load()
2018-03-15T18:04:49.163872+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-03-15T18:04:49.163876+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-03-15T18:04:49.163878+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-03-15T18:04:49.163874+00:00 app[web.1]:     return self.load_wsgiapp()
2018-03-15T18:04:49.163881+00:00 app[web.1]:     __import__(module)
2018-03-15T18:04:49.163880+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
2018-03-15T18:04:49.164035+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-15T18:04:49.308012+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Shutting down: Master
2018-03-15T18:04:49.163889+00:00 app[web.1]: ModuleNotFoundError: No module named 'mysite.wsgi'
2018-03-15T18:04:49.308186+00:00 app[web.1]: [2018-03-15 18:04:49 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-03-15T18:04:49.754383+00:00 heroku[web.1]: State changed from starting to crashed

wsgi.py

`
"""
WSGI config for mysite project.

It exposes the WSGI callable as a module-level variable named 
application.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

2 Answers2

1

SOLUTION:

The problem was the location of my Procfile file: it has to be on the same path as manage.py. That's all!

0

Your gunicorn start command looks strange:

Starting process with command `gunicorn mysite.wsgi --log-file -`

The command should specify the module name and variable name separated with a colon, like this:

gunicorn mysite.wsgi:application
Will Keeling
  • 22,055
  • 4
  • 51
  • 61
  • Still failling. I tried moving my Procfile inside the same path as manage.py, adding what you said, but still getting errors. This time, I got this, among other things `[2018-03-15 21:43:01 +0000] [4] [INFO] Starting gunicorn 19.7.1 2018-03-15T21:43:01.472311+00:00 app[web.1]: [2018-03-15 21:43:01 +0000] [8] [ERROR] Exception in worker process` – Ignacio Gazzaniga Mar 15 '18 at 21:53
  • Is the trace back exactly the same as before, or different this time? – Will Keeling Mar 18 '18 at 12:21