rails 4: custom error pages for 404, 500 and where does the default 500 error message come from?


Currently in production im getting this text:

500 Internal Server Error
If you are the administrator of this website, then please read this web application's
log file and/or the web server's log file to find out what went wrong.

No html in that page nothing.

Where is this code situated? I have no public/500.html or anything in that regard.

In my routes I have:

  get "/404", :to => "errors#error_404"
  get "/422", :to => "errors#error_404"
  get "/500", :to => "errors#error_500"
  get "/505", :to => "errors#error_505"


class ErrorsController < ApplicationController

  def sub_layout

  def error_404
    render :status => 404, :formats => [:html], :layout => "white", :sub_layout => "left"

  def error_422
    render :status => 422, :formats => [:html], :layout => "white", :sub_layout => "left"

  def error_500
    render :status => 500, :formats => [:html], :layout => "white", :sub_layout => "left"

  def error_505
    render :status => 505, :formats => [:html], :layout => "white", :sub_layout => "left"


How to make it load my custom errors always? On some errors it just throw that 2 line text coming somewhere from rails core, I want it to pickup my custom styled error pages every time! how? thx!

The Error you are experiencing is being thrown from


This means, the code your exceptions are getting rescued by are themselves throwing exceptions. You can check your logs for text:

Error during failsafe response:

to identify what the exceptions really are originating from and thus solve your problem.