Debugging a New Django Site on Webfaction

Your Django site works fine in dev. You put it on a server and get:

502 Bad Gateway

You look at the error log and the error does not trace back to any of your code. The traceback starts like this:

Traceback (most recent call last):
  File "/home/my_site/.virtualenvs/my_env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
    response = self.get_response(request)
  File "/home/my_site/.virtualenvs/my_env/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/my_site/.virtualenvs/my_env/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
    return callback(request, **param_dict)
  File "/home/my_site/.virtualenvs/my_env/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/my_site/.virtualenvs/my_env/lib/python2.7/site-packages/django/views/defaults.py", line 41, in server_error
    return http.HttpResponseServerError(template.render(Context({})))

In my case, I used django-compressor so the traceback ends with:

File "/home/my_site/.virtualenvs/my_env/lib/python2.7/site-packages/compressor/parser/lxml.py", line 20, in __init__
 raise ImproperlyConfigured("Error while importing lxml: %s" % err)
django.core.exceptions.ImproperlyConfigured: Error while importing lxml: No module named BeautifulSoup

To debug, I set DEBUG=True in my settings file. Suddenly the error went away.

In this case, I also had:

EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend

If email was on, I would have gotten a message that resolved this problem.

So what’s the answer? The setting:

ALLOWED_HOSTS

was wrong.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s