nginx gives 502 for non handled exception 500 error in flask
Look at the 502 spec:

The HyperText Transfer Protocol 502 Bad Gateway server error response
  code indicates that the server, while acting as a gateway or proxy,
  received an invalid response from the upstream server.

If your app responds anything while hitting an exception, it's most likely garbage and nginx raises (correctly) the 502, meaning "I won't (as opposed to can't) talk to the backend".
If you want 500s, you have to catch any possible underlying exception, wrap it in a valid response and it will be processed by nginx.
I am running a Flask application and using uwsgi socket nginx configuration.
This may be a stupid question but the issue I am facing is that whenever there is exception raised in Flask code (non handled exception for example 1/0), my nginx gives 502 instead of 500. I wanted to know if raising the exception is not getting propagated to nginx as 500 from uwsgi unix socket by default or do I need to specify this explicitly? Somewhere I read that for exceptions, Flask doesn't raise 500 error message automatically. Any comments will be helpful. Thanks.