[Fixed]-Django uWSGI NGINX Bad Request 400


Since I asked this question over 5 years ago, I might be wrong.
But I’m gonna answer it now as best I can, since all the answers coming up seem to be far off from my solution(s).

I recently used Django again for a few projects and had a similar problem.

List of what I was doing wrong:

  • Had uwsgi installed in the virtualenv as well as globally on the system
  • Wrong path to the app in the uwsgi-config
  • Wrong path to the virtualenv in the uwsgi-config
  • Permissions for the socket-file for connecting uwsgi and nginx were set incorrectly

That’s all I can think of, what I’ve been doing wrong, back in the day.

I hope this helps all of you, who struggle with the setup.


In settings.py


Will solve it



You can set DEBUG = True on your server, restart uwsgi service and check the django‘s debug output in your browser. The fact you don’t see any errors with django‘s development server doesn’t mean the error is related to nginx or uwsgi services.



Okay so I got this same error but I finally figured it out. (At least for me). I pray to god this works for you because I wasted a day on this.

If you’re like me you used: http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html as a tutorial to get the basic setup. I got uwsgi to work over http and it seemed to work over tcp socket. As soon as I tried to hook up nginx, I kept getting 400 errors. It specifically says create a file name my_site.conf and link that to sites-enabled. Well if you check sites-enabled you should see a file named default. Notice this file isn’t named default.conf. Try renaming my_site.conf to my_site and make sure to re-link.

TDLR: Unlink my_site.conf. Rename my_site.conf to my_site. Link my_site to sites-enabled

Leave a comment