Bad request 400: nginx / gunicorn

I had the same problem and adding ALLOWED_HOSTS = ("yourdomain.com",) to settings fixed it.

UPDATE: there few other possibilities:

  1. Nginx (or whatever web server you use) doesn’t pass the $host variable to the app
  2. Host contains underscores

See details: https://blog.anvileight.com/posts/how-to-fix-bad-request-400-in-django/

Leave a Comment