500 Server Error on DEBUG = False in Django with gunicorn and whitenoise, heroku
<p>As it seems with all the other debug based questions on here, my app produces a 500 error after switching to debug = false.  I followed <a href="https://www.youtube.com/watch?v=8Qcqh0jl5YU" rel="nofollow">this</a> video on deploying django projects with heroku with success until I reached DEBUG.</p>

<p>I've already tried...</p>

<pre><code>ALLOWED_HOSTS = ['*'] # didn't change anything
adding a trailing forward slash '/' to links # didn't change anything

8/24/2016

added /favicon.ico url # eliminated related error
added favicon.02c31ae25a91.ico file # eliminated related error
</code></pre>

<p>--- settings.py ---</p>

<pre><code>import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

DEBUG = False

ALLOWED_HOSTS = ['.appname.herokuapp.com'] # appname is just a placeholder here

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'apps.home',
    'apps.quiz',
    'apps.store',
    'apps.accounts',
]

MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'first_project.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'first_project.wsgi.application'

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':     'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':     'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME':     'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME':     'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

# added for heroku
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATIC_ROOT = os.path.join((BASE_DIR), 'static')
</code></pre>

<p>--- urls.py ---</p>

<pre><code>from django.conf.urls import patterns, url
from . import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
    url(r'^show/(?P&lt;chord_id&gt;\w+)/$', views.show, name='show'),
    url(r'^chords$', views.chords, name='chords'),
    url(r'^review_us$', views.review_us, name='review_us'),
    url(r'^submit_review$', views.SubmitReview.as_view(), name='submit_review'),
    url(r'^reviews$', views.reviews, name='reviews'),
    url(r'^discovery$', views.discovery, name='discovery')
)
</code></pre>

<p>--- views.py ---</p>

<pre><code>def index(request):
    # return HttpResponse("You are looking at question number %s." % question_id)

    # if int(question_id) == 1:
    #   return HttpResponse('&lt;h1&gt;Page found!&lt;/h1&gt;')
    # else:
    #   raise Http404

    # if int(question_id) == 1:
    #   return HttpResponse('&lt;h1&gt; Page found! &lt;/h1&gt;')
    # else:
    #   return HttpResponseNotFound('&lt;h1&gt; Page not found! &lt;/h1&gt;')

    context = {
        'assertions': [
        { 'id': 1, 'content': 'Django Landing Page'},
        { 'id': 2, 'content': 'Second value'},
        { 'id': 3, 'content': 'Third value'},
        { 'id': 4, 'content': 'Fourth value'},
            ]
        }

    return render(request, 'home/index.html', context)
</code></pre>

<p>--- heroku logs ---</p>

<pre><code>2016-08-23T23:24:30.258910+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-08-23T23:24:30.277985+00:00 heroku[web.1]: Restarting
2016-08-23T23:24:30.278655+00:00 heroku[web.1]: State changed from up to startin
g
2016-08-23T23:24:33.838679+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-23T23:24:34.619593+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-23T23:24:35.632013+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-23T23:24:35.636996+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Handling signal: term
2016-08-23T23:24:35.640739+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-23T23:24:35.696136+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Shutting down: Master
2016-08-23T23:24:35.610297+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:4293 (3)
2016-08-23T23:24:35.610447+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Using worker: sync
2016-08-23T23:24:35.614711+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-23T23:24:35.609886+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-23T23:24:35.646281+00:00 app[web.1]: [2016-08-23 23:24:35 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-23T23:24:35.889214+00:00 heroku[web.1]: Process exited with status 0
2016-08-23T23:24:36.004541+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-23T23:25:54.160914+00:00 heroku[api]: Starting process with command `pyt
hon manage.py collectstatic` by brian.eddow@gmail.com
2016-08-23T23:25:58.277888+00:00 heroku[run.3353]: Awaiting client
2016-08-23T23:25:58.304948+00:00 heroku[run.3353]: Starting process with command
 `python manage.py collectstatic`
2016-08-23T23:25:58.481426+00:00 heroku[run.3353]: State changed from starting t
o up
2016-08-23T23:26:08.355832+00:00 heroku[run.3353]: Process exited with status 1
2016-08-23T23:26:08.366477+00:00 heroku[run.3353]: State changed from up to comp
lete
2016-08-23T23:26:20.356441+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=20a28fca-d7f9-406b-9110-06f0f8e265f4 fwd="10
8.201.188.39" dyno=web.1 connect=0ms service=75ms status=500 bytes=239
2016-08-23T23:30:12.593525+00:00 heroku[api]: Deploy bcdede2 by brian.eddow@gmai
l.com
2016-08-23T23:30:12.593630+00:00 heroku[api]: Release v83 created by brian.eddow
@gmail.com
2016-08-23T23:30:12.827280+00:00 heroku[slug-compiler]: Slug compilation started

2016-08-23T23:30:12.827285+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-08-23T23:30:12.875797+00:00 heroku[web.1]: Restarting
2016-08-23T23:30:12.878934+00:00 heroku[web.1]: State changed from up to startin
g
2016-08-23T23:30:15.128700+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-23T23:30:15.675480+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-23T23:30:15.675491+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-23T23:30:15.675492+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [3] [IN
FO] Handling signal: term
2016-08-23T23:30:15.676931+00:00 app[web.1]: [2016-08-23 23:30:15 +0000] [3] [IN
FO] Shutting down: Master
2016-08-23T23:30:15.769076+00:00 heroku[web.1]: Process exited with status 0
2016-08-23T23:30:16.401830+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-23T23:30:18.414541+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:20560 (3)
2016-08-23T23:30:18.414678+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [3] [IN
FO] Using worker: sync
2016-08-23T23:30:18.413989+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-23T23:30:18.419387+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-23T23:30:18.451925+00:00 app[web.1]: [2016-08-23 23:30:18 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-23T23:30:20.092572+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-23T23:30:21.599823+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=d04b82a0-845b-4098-b78e-95538974b682 fwd="10
8.201.188.39" dyno=web.1 connect=0ms service=59ms status=500 bytes=239
2016-08-24T00:03:49.213687+00:00 heroku[web.1]: State changed from up to down
2016-08-24T00:03:49.213151+00:00 heroku[web.1]: Idling
2016-08-24T00:03:51.783907+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-24T00:03:52.532466+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-24T00:03:52.528309+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-24T00:03:52.528563+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [3] [IN
FO] Handling signal: term
2016-08-24T00:03:52.644328+00:00 app[web.1]: [2016-08-24 00:03:52 +0000] [3] [IN
FO] Shutting down: Master
2016-08-24T00:03:52.782407+00:00 heroku[web.1]: Process exited with status 0
2016-08-24T00:58:31.329461+00:00 heroku[web.1]: Unidling
2016-08-24T00:58:31.329760+00:00 heroku[web.1]: State changed from down to start
ing
2016-08-24T00:58:35.650617+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-24T00:58:37.722538+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-24T00:58:37.723001+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:58399 (3)
2016-08-24T00:58:37.723085+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [3] [IN
FO] Using worker: sync
2016-08-24T00:58:37.807193+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-24T00:58:37.727390+00:00 app[web.1]: [2016-08-24 00:58:37 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-24T00:58:39.340476+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-24T00:58:40.556179+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=41fd5fa1-d91b-4c9b-8988-b18102ca8dbe fwd="10
8.201.188.39" dyno=web.1 connect=1ms service=62ms status=500 bytes=239
2016-08-24T01:33:02.714290+00:00 heroku[web.1]: Idling
2016-08-24T01:33:02.714953+00:00 heroku[web.1]: State changed from up to down
2016-08-24T01:33:06.080166+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-24T01:33:06.850885+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-24T01:33:06.866811+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [3] [IN
FO] Handling signal: term
2016-08-24T01:33:06.850898+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-24T01:33:06.880540+00:00 app[web.1]: [2016-08-24 01:33:06 +0000] [3] [IN
FO] Shutting down: Master
2016-08-24T01:33:07.004257+00:00 heroku[web.1]: Process exited with status 0
2016-08-24T19:49:46.766158+00:00 heroku[web.1]: Unidling
2016-08-24T19:49:46.766448+00:00 heroku[web.1]: State changed from down to start
ing
2016-08-24T19:49:51.590527+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-24T19:49:53.555121+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-24T19:49:53.555711+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [3] [IN
FO] Using worker: sync
2016-08-24T19:49:53.555605+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:38921 (3)
2016-08-24T19:49:53.617284+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-24T19:49:53.559598+00:00 app[web.1]: [2016-08-24 19:49:53 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-24T19:49:55.155379+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-24T19:49:56.927053+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=ca7b4765-90cb-4908-ad56-3ae39f535777 fwd="10
8.201.188.39" dyno=web.1 connect=1ms service=59ms status=500 bytes=239
2016-08-24T19:49:57.471151+00:00 heroku[router]: at=info method=GET path="/favic
on.ico" host=chordjam.herokuapp.com request_id=196b6576-1aed-45d1-b21d-c3f316f82
02e fwd="108.201.188.39" dyno=web.1 connect=0ms service=30ms status=302 bytes=27
8
2016-08-24T19:49:57.581950+00:00 heroku[router]: at=info method=GET path="/stati
c/favicon.02c31ae25a91.ico" host=chordjam.herokuapp.com request_id=5ce248c4-e25f
-4c69-badf-7bd395876493 fwd="108.201.188.39" dyno=web.1 connect=0ms service=3ms
status=404 bytes=305
2016-08-24T19:51:47.100779+00:00 heroku[slug-compiler]: Slug compilation started

2016-08-24T19:51:47.100784+00:00 heroku[slug-compiler]: Slug compilation finishe
d
2016-08-24T19:51:47.083765+00:00 heroku[web.1]: Restarting
2016-08-24T19:51:47.084557+00:00 heroku[web.1]: State changed from up to startin
g
2016-08-24T19:51:46.883892+00:00 heroku[api]: Release v84 created by brian.eddow
@gmail.com
2016-08-24T19:51:46.883892+00:00 heroku[api]: Deploy 9843b18 by brian.eddow@gmai
l.com
2016-08-24T19:51:49.386648+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-08-24T19:51:49.960873+00:00 app[web.1]: [2016-08-24 19:51:49 +0000] [9] [IN
FO] Worker exiting (pid: 9)
2016-08-24T19:51:50.096207+00:00 app[web.1]: [2016-08-24 19:51:50 +0000] [3] [IN
FO] Shutting down: Master
2016-08-24T19:51:49.961498+00:00 app[web.1]: [2016-08-24 19:51:49 +0000] [10] [I
NFO] Worker exiting (pid: 10)
2016-08-24T19:51:49.960884+00:00 app[web.1]: [2016-08-24 19:51:49 +0000] [3] [IN
FO] Handling signal: term
2016-08-24T19:51:50.216478+00:00 heroku[web.1]: Process exited with status 0
2016-08-24T19:51:51.873593+00:00 heroku[web.1]: Starting process with command `g
unicorn first_project.wsgi --log-file -`
2016-08-24T19:51:54.552846+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [9] [IN
FO] Booting worker with pid: 9
2016-08-24T19:51:54.548218+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [3] [IN
FO] Using worker: sync
2016-08-24T19:51:54.548216+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [3] [IN
FO] Listening at: http://0.0.0.0:13574 (3)
2016-08-24T19:51:54.592965+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [10] [I
NFO] Booting worker with pid: 10
2016-08-24T19:51:54.547456+00:00 app[web.1]: [2016-08-24 19:51:54 +0000] [3] [IN
FO] Starting gunicorn 19.6.0
2016-08-24T19:51:55.606463+00:00 heroku[web.1]: State changed from starting to u
p
2016-08-24T19:51:56.802850+00:00 heroku[router]: at=info method=GET path="/" hos
t=chordjam.herokuapp.com request_id=06f8f828-0823-48c2-9f84-bc81bc0e86b8 fwd="10
8.201.188.39" dyno=web.1 connect=0ms service=131ms status=500 bytes=239
</code></pre>

<p>I've read through many of the other questions and responses on here trying most of the offered solutions.  If I can offer any other code to help someone help me, please let me know, at this point I feel like I am shooting in the dark.</p>

<p>8/24/2016 - From heroku logs it looks like it's restarting after slug compilation but I'm not familiar enough with the logs to accurately read these errors.</p>