I've changed DEBUG to True in settings.py of my django project and it works fine now.
Bad Request (400) after making supervisor restart
-
29-06-2023 - |
Pregunta
After restarting my django app: supervisorctl restart [process]
I've got Bad Request(400) error when visiting my site. The app is under nginx with gunicorn and supervisor.
I remember to had the same problem some time ago and restarting supervisor from some specific folder on the server had helped. I've tried to restart supervisor from different locations, however it doesn't help.
nginx-error.log
2014/04/08 06:45:23 [error] 9635#0: *9 connect() to unix:/webapps/filmyposlowie/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: 78.10.91.212, server: filmyposlowie.pl, request: "GET / HTTP/1.1", upstream:
"http://unix:/webapps/filmyposlowie/run/gunicorn.sock:/"
, host: "filmyposlowie.pl"
Solución 3
Otros consejos
I have the same issue, I solved it by adding these two lines in my nginx's server config file
proxy_set_header Host $http_host;
proxy_redirect off;
When you change DEBUG
setting to False
, you must also set ALLOWED_HOSTS
.
You may simply make Django accept requests by allowing localhost:
ALLOWED_HOSTS = ['127.0.0.1']
This will work if gunicorn is running on same machine and it is bound to 127.0.0.1
Ref: DEBUG
Finally, if DEBUG is False, you also need to properly set the ALLOWED_HOSTS setting. Failing to do so will result in all requests being returned as “Bad Request (400)”.