TheGRS TheGRS - 1 year ago 43
Python Question

Can't deploy Django application in Heroku cloud

I cannot seem to deploy my Django application through

. Here is my

web: gunicorn config.wsgi:application

My wsgi file is not located under the project, but under a config folder instead

import os

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)

I'm using the
heroku local
tool to try to test this and I am running into this error:

$heroku local
forego | starting web.1 on port 5000
web.1 | [2015-11-22 10:05:29 -0800] [32081] [INFO] Starting gunicorn 19.3.0
web.1 | [2015-11-22 10:05:29 -0800] [32081] [INFO] Listening at: (32081)
web.1 | [2015-11-22 10:05:29 -0800] [32081] [INFO] Using worker: sync
web.1 | [2015-11-22 10:05:29 -0800] [32084] [INFO] Booting worker with pid: 32084
web.1 | [2015-11-22 10:05:29 -0800] [32084] [ERROR] Exception in worker process:
web.1 | __import__(module)
web.1 | hon2.7/site-packages/gunicorn/app/", line 65, in load
web.1 | [2015-11-22 10:05:29 -0800] [32084] [INFO] Worker exiting (pid: 32084)
web.1 | [2015-11-22 10:05:29 -0800] [32081] [INFO] Shutting down: Master
web.1 | [2015-11-22 10:05:29 -0800] [32081] [INFO] Reason: Worker failed to boot.

I've been trying to read about Procfile configurations and gunicorn for several hours and have tried different configurations of this, even trying to put the wsgi file under the application and changing the application name, all to no avail. This seems like something obvious that I am missing. Any ideas?

Updating with a little bit of my project structure below. It is based on the structure from Two Scoops of Django and can be found on the cookiecutter-django project.



You have to let gunicorn listen to the port specified by the $PORT environment variable. I do something like this:

web: gunicorn -w 4 -b$PORT app:app

I think you are probably calling all your modules correctly.