title: Debugging a Flask app running in Gunicorn
body: <p>I've been working on a new dev platform using nginx/gunicorn and Flask for my application.</p>
  
  <p>Ops-wise, everything works fine - the issue I'm having is with debugging the Flask layer. When there's an error in my code, I just get a straight 500 error returned to the browser and nothing shows up on the console or in my logs.</p>
  
  <p>I've tried many different configs/options.. I guess I <strong>must</strong> be missing something obvious.</p>
  
  <p>My gunicorn.conf:</p>
  
  <pre><code>import os
  
  bind = '127.0.0.1:8002'
  workers = 3
  backlog = 2048
  worker_class = "sync"
  debug = True
  proc_name = 'gunicorn.proc'
  pidfile = '/tmp/gunicorn.pid'
  logfile = '/var/log/gunicorn/debug.log'
  loglevel = 'debug'
  </code></pre>
  
  <p>An example of some Flask code that borks- testserver.py:</p>
  
  <pre><code>from flask import Flask
  from flask import render_template_string
  from werkzeug.contrib.fixers import ProxyFix
  
  app = Flask(__name__)
  
  @app.route('/')
  def index():
      n = 1/0
      return "DIV/0 worked!"
  </code></pre>
  
  <p>And finally, the command to run the flask app in gunicorn:</p>
  
  <pre><code>gunicorn -c gunicorn.conf.py testserver:app
  </code></pre>
  
  <p>Thanks y'all</p>