Nginx bad gateway (502) error on django 500 errors (instead of showing django 500 page) with DEBUG = False setting

djangonginxuwsgi

I have a problem with my current setup… And the issue is, that if i set DEBUG = False in django settings.py file nginx stops showing django tracebacks on 500 errors, but does not show our 500 page either. It just displays nginx 502 bad gateway error.

I do get the email error with traceback, just as i've configured it to mail tracebacks to me, when they occur. But i want to display nice 500 page to users not nginx 502 gateway error…

Honestly, i dont even know where to begin searching the root of the problem. Im prepared to post all necessary config files, if some nginx expert would come and tell me what he wants to see.

alan

Edit1: I looked up what log file shows at one of those 500 errors, and it shows this:

[pid: 16203|app: 0|req: 1/1] my.ip.address () {46 vars in 915 bytes} [Thu Sep 12 10:01:17 2013] GET /settings/personal/ => generated 0 bytes in 1249 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

Does this mean that its somehow django fault cause it looks like django returned 0 bytes?

Best Answer

Does this mean that its somehow django fault cause it looks like django returned 0 bytes?

Yes, there is no nginx issue here, the problem is that Django returns nothing instead of a 500 error page.