title: How do I debug a HTTP 502 error?
body: <p>I have a Python Tornado server sitting behind a nginx frontend.  Every now and then, but not every time, I get a 502 error.  I look in the nginx access log and I see this:</p>
  
  <pre><code>127.0.0.1 - - [02/Jun/2010:18:04:02 -0400] "POST /a/question/updates HTTP/1.1" 502 173 "http://localhost/tagged/python" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
  </code></pre>
  
  <p>and in the error log:</p>
  
  <pre><code>2010/06/02 18:04:02 [error] 14033#0: *1700 connect() failed (111: Connection refused)
  while connecting to upstream, client: 127.0.0.1, server: _,
  request: "POST /a/question/updates HTTP/1.1",
  upstream: "http://127.0.0.1:8888/a/question/updates", host: "localhost", referrer: "http://localhost/tagged/python"
  </code></pre>
  
  <p>I don't <em>think</em> any errors show up in the Tornado log.  How would you go about debugging this?  Is there something I can put in the Tornado or nginx configuration to help debug this?</p>