We have a client that would like to see a branded, non-EE error message if there is a problem with the EE database connection. Their database is hosted on a different server and has, on one or two occasions, lost the connection – causing EE to render a plain error message.

We'd either like to redirect to a static HTML page which contains a nice, branded apology for the site being down, or to edit the source code of the default message. I tried the Custom Messages add-on but it seems that this requires EE and the DB to be functioning correctly in order to work.

Any thoughts on how best to approach this scenario?


  • Would love to see the final answer written out clearly and selected. Aug 15, 2013 at 13:39

1 Answer 1


This might help:


I suspect you will have to insert something like this in the site root index.php for it to work, you could then include a static template from somewhere else on the server when a connection can't be made and serve a 404 header?

  • Thanks Nathan. Yeah, I guess that would work: if (mysql_connect(...)) { require_once BASEPATH.'core/CodeIgniter'.EXT; } else { redirect... }
    – GazCrane
    Jul 16, 2013 at 13:14
  • I would avoid doing a redirect personally as a user might click 'Refresh' after seeing the message and in this scenario they wouldn't get routed back to the page they requested. :) Jul 16, 2013 at 13:16
  • Good point. Thoughts on serving a 503? if (mysql_connect(...)) { header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 3600'); include 'static_template.php'; } else { require_once BASEPATH.'core/CodeIgniter'.EXT; }
    – GazCrane
    Jul 16, 2013 at 13:48
  • Oops, wrong way around...but you get the idea ;-)
    – GazCrane
    Jul 16, 2013 at 13:50
  • 1
    Hi Gary - would be great if you could mark this question an answered by my suggestion or add your own answer with a code snippet. ;) Aug 6, 2013 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.