Django error

Updated 11 October 2026

Short answer

Django's docs are blunt: never run production with DEBUG on. With it off, visitors see a plain error page, and the traceback goes to your logs (or to the admins' email, if configured). Read those. Two common production problems: every page returning 400 Bad Request, which usually means your domain isn't in ALLOWED_HOSTS, and missing styles, which usually means static files weren't collected or aren't served.

What's the problem

Your Django site shows "Server Error (500)", "Bad Request (400)" on every page, missing CSS, or database errors after a deploy.

Why it happens

  • ALLOWED_HOSTS doesn't include the domain being used (400 on every page).
  • An exception in a view, often a database or outside API call.
  • Migrations not run on production.
  • Static files not collected or not served.
  • Environment settings (secret key, database URL) missing in production.
  • The app server (Gunicorn, uWSGI) crashed behind Nginx (502).

How to fix it

  1. Read your app server logs for the traceback.
  2. For 400 on every page, add your domain (and www) to ALLOWED_HOSTS.
  3. Run migrations on production.
  4. Run collectstatic and check your web server serves the static folder.
  5. Check production environment settings.
  6. Keep DEBUG = False in production.

What Preventionlabs checks

One click runs the full report on your domain. For this problem it shows whether your site loads, how fast, and where its redirects go; up to 50 pages from your sitemap, listing any that fail or are slow, plus broken links on them. With Cloudflare connected, it also shows which pages returned server errors (5xx) to visitors, and when; recent deploys and account changes, with their times. It doesn't read your server logs, so the exact error message is in your host's logs.

Run your free report

Your first report is free, no card needed. Then A$50 a month, up to 10 domains. Read-only: it never changes anything.

Sources

  1. Django: Settingsofficial docsNever deploy a site into production with DEBUG turned on.
  2. Django: Settingsofficial docsA list of strings representing the host/domain names that this Django site can serve.

Preventionlabs is independent and not affiliated with Django. Product names are used only to describe the problem.

← All of Frameworks