Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging 500 error on Heroku without any error message

This is driving me nuts. There is no error in development environment. There was no error in production environment when I deployed to Amazon EC2.

However, on Heroku, it is giving me a 500 error when accessing a particular page. There is no other message than 500 error message.

2012-10-09T06:50:02+00:00 app[web.1]: Completed 500 Internal Server Error in 72ms (Views: 11.5ms | ActiveRecord: 44.2ms)

That's all I have. No other error message. I even set the logging level to "DEBUG".

What can I do to find out what's causing the 500 error on Heroku?

I appreciate your help.

like image 940
yangtheman Avatar asked May 20 '26 13:05

yangtheman


2 Answers

Have you checked your assets are being precompiled on deploy to Heroku? A broken asset pipeline can create 500 errors with little logged explanation at runtime.

like image 148
Aaron B. Russell Avatar answered May 23 '26 04:05

Aaron B. Russell


It turned out to be nothing to do with sass. I had to catch 500 error and display stack trace to figure out exactly what was causing the error and fix it.

In the helper function, I had

rand(1..size)

and that was causing the error on Heroku, but not on development environment nor on EC2. I had to modify it to

rand(size)

and that fixed it.

After printing stack trace, it was easy to pinpoint what was causing the error.

I wrote a blog post about catching 400 and 500 errors so that you can do more interesting things.

http://blog.yangtheman.com/2012/10/11/user-friendly-500-and-404-pages-on-rails-3/

like image 44
yangtheman Avatar answered May 23 '26 04:05

yangtheman