# Mongrel - "Status: 500" appears in HTTP response body, not headers

**URL:** <https://www.ruby-forum.com/t/mongrel-status-500-appears-in-http-response-body-not-headers/122731>\
**Category:** Rails\
**Created:** [December 11, 2007, 1:38pm UTC](https://www.ruby-forum.com/t/mongrel-status-500-appears-in-http-response-body-not-headers/122731 "2007-12-11T13:38:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Westcott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@Matt\_Westcott](https://www.ruby-forum.com/u/Matt_Westcott)\
**Post date:** [December 11, 2007, 1:38pm UTC](https://www.ruby-forum.com/t/mongrel-status-500-appears-in-http-response-body-not-headers/122731/1 "2007-12-11T13:38:08Z")

</div>

Hi,  
On Rails 1.2.5 (and also edge Rails) with Mongrel 1.1.1, the 500  
Internal Server Error status code for the 500.html failsafe page isn’t  
being served correctly. It appears at the top of the HTTP response  
body, but the actual response is sent with status 200 OK.

Specifically, this happens when a database error occurs while  
active\_record\_store sessions are in use. To replicate:  
Create a fresh rails project (but deliberately don’t create the  
corresponding database):  
rails db\_failure\_test  
Edit config/environment.rb and uncomment the line  
config.action\_controller.session\_store = :active\_record\_store  
Start script/server, and visit  
[http://localhost:3000/test/](http://localhost:3000/test/)

The text “Status: 500 Internal Server Error Content-Type: text/html”  
appears at the top of the response, but inspecting the headers using  
the Firefox LiveHTTPHeaders extension (or raw HTTP over telnet), it’s  
actually served as a 200 OK response.

This is a bit of an irritation, partly because I’d prefer not to have  
technobabble appearing on my friendly error pages, but mostly because  
I’d like to set up Nagios monitoring to catch the 500 status when the  
database falls over.

I’ve had an initial poke at the code, but ultimately it’s not clear  
whether this is a Mongrel or Rails bug - and it’s also a bit tricky to  
google (because understandably, people tend to be more interested in  
getting rid of errors than serving them correctly…). Any suggestions  
about what I can tweak, or at least which project I should be sending  
a bug report to?

Cheers,

- Matt
