Broken pipe error in Flask server

I am using Flask for some of my internal services. If you haven't used Flask, I would absolutely recommend that you check it out.

Recently I got the following error while I was attempting to serve a page from template. In an attempt to troubleshoot the error, I wasted almost half an hour. - - [19/Jun/2012 17:48:37] "POST /" 500 -
Exception happened during processing of request from ('', 55176)
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/", line 310, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/", line 641, in __init__
  File "/usr/lib/python2.7/", line 694, in finish
  File "/usr/lib/python2.7/", line 303, in flush
error: [Errno 32] Broken pipe

If you happen to receive this error, most likely cause is that the template you are attempting to render using "render_template" function is not found under PROJ_ROOT/templates directory. All the templates should be present under the PROJ_ROOT/templates directory. Unfortunately you don't see an accurate error message indicating that the template is missing!


PyGuy said…
I ran into this today and it looks like it's just the browser closing the connection before the request has finished server side. I tested by creating a flask view that returned "hi" and it was still possible to get these errors depending on how I hit the flask-server from my webserver. I hope this information helps!
Dinesh said…
Thanks for the post. That's what exactly happened to me.

Popular posts from this blog

Note on allocationSize parameter of @SequenceGenerator while using JPA

The mysterious ORA-03111 error

Creating a Collection with a single element