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

Awesome tip. I've been banging my head up against a wall for days on this one.

It's worth noting that on shared hosts, you'd need to look at cPanel for the error logs, because fastcgi.crash.log doesn't have anything helpful.
Thaaaanks! I've been banging my head over this for a half an hour... log/development.log was saying everything is fine, there was no error on my local Mongrel, and I was clueless... Then it hit me: checked Apache's error.log, gooogled that and I ended up on your page.


I was briefly tearing my hair out: "Why does it work on WeBRICK and not Apache?!?! ARGHH!!" Hah. Anyway thanks a lot for this tip. 2 years later and this is still a problem. Unbelievable.
Thanks this article was very helpful. The error statement is weird and gives no hint on what's going wrong in ssl mode.
Post a Comment

<< Home

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