Is there any way to get Craft 3 to display 404.html and 503.html for the 404 and 503 pages while in devMode, as it did in Craft 2, rather than returning the entire Yii 2 error stack?

Sometimes, we have to bring a site temporarily offline (by way of toggle in the general settings tab) to add features, and we have to put it into dev mode for debug. We want the site to show the branded 503 page to the public instead of the stack page.

  • I'm confused... taking the site offline doesn't enable devMode?
    – Brad Bell
    Jan 23 '18 at 0:28
  • Is that a thing? 0___0; Is this a new feature or has this always been the way it's been?
    – Dustin C
    Jan 23 '18 at 1:07
  • 1
    I think he's saying that they take the site offline and sometimes enable devMode during that time to help them debug things. Jan 23 '18 at 13:02
  • 2
    @andrew.welch - Exactly! Does disabling a site through the control panel enable dev mode, though? If so - I never knew that was a feature, as it's not talked about very much. (That would be cool! And helpful.)
    – Dustin C
    Jan 23 '18 at 18:02
  • Same here, I didn't know that was a feature until just now :-)
    – Jan
    Jul 9 '18 at 7:40

Just posting this here since I saw an official answer in Github:

This changed in Beta 7:

UserException reports are now styled like other exceptions when Dev Mode is enabled, with the full stack trace shown.

You can see your 404 template by requesting it directly, e.g. http://mysite.dev/404



Another option is to check the response code directly in your config/general.php file.

'devMode' => http_response_code() == 200,

I suspect this "solution" will make peoples toes curl; as it's a bit hacky and probably won't work in all cases. So I'd recommend using this only in your dev environments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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