Sunday, January 14, 2007

Ruby On Rails + FastCGI / fcgi malformed header error

For RoR applications running on fcgi
If you are getting a 500 error on some page and the only error you see on the server side is

FastCGI: comm with server "//public/dispatch.fcgi" aborted: error parsing headers: malformed header 'some text here'

This is NOT because of any configuration issues with fcgi etc. You are doing "puts" somewhere (or trying to write to stdout somehow) in your application.
Just run this to catch the culprit and change puts to logger.debug or just remove it:

find . -name '*.rb' -exec grep -q 'puts' '{}' \; -print

This page is powered by Blogger. Isn't yours?