<p>Craft will serve one of 3 types of 404 errors.</p>

<p>When Dev Mode is enabled, you will get something like this, which shows the full stack trace leading up to the NotFoundHttpException:</p>

<p><a href="https://i.sstatic.net/PAWnH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PAWnH.png" alt="enter image description here"></a></p>

<p>If this looks like what you’re getting, then Dev Mode is <em>definitely</em> enabled. Double-check <code>config/general.php</code> for <code>devMode</code>, or <code>web/index.php</code> for <code>YII_DEBUG</code>.</p>

<p>Otherwise, you will get something like this in Craft’s Control Panel (as well as the front end if you haven’t specified a 404 template yet):</p>

<p><a href="https://i.sstatic.net/qlvoL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qlvoL.png" alt="enter image description here"></a></p>

<p>If it’s a front-end request, <em>and</em> you have a 404 template, then Craft will render your 404 template. If it encounters an error when trying to do that, a plain text error will be displayed, with no styling.</p>

CC BY-SA 4.0
2018-09-19T12:45:54.683Z
`devMode` is set to `false` in `config/general.php` I swear! Is there any way to get Craft to dump what this value is before rendering the error to verify?
Mike F
CC BY-SA 4.0
2018-09-19T12:55:10.843Z
@MikeF Try going into your Control Panel - do you see the stripes in the top-left that indicate that Dev Mode is enabled?
Brandon Kelly
CC BY-SA 4.0
2018-09-19T13:00:14.000Z
Nothing there, still getting the same errors :(
Mike F
CC BY-SA 4.0
2018-09-19T13:07:20.777Z
OK, can you send a database backup, your `composer.json`, `composer.lock`, and config & template files over to support@craftcms.com, and tell us which URL you're getting this on? We can try reproducing it with those.
Brandon Kelly
CC BY-SA 4.0
2018-09-19T11:49:18.080Z
2018-09-19T14:11:44.910Z
2018-09-19T14:11:44.910Z
Brandon Kelly
<p>If you've set devMode to <code>false</code> in your local environment and you <em>still</em> can't see your 404 template, go to your own user account in the CMS and uncheck "Show full exception views when Dev Mode is disabled".</p>

<p><a href="https://i.sstatic.net/D4sxJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/D4sxJ.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2020-01-31T23:41:00.420Z
2020-01-31T23:41:00.420Z
Ryan
<p>There's a long discussion of all of this in the <a href="https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms#handling-exceptions-on-the-frontend" rel="nofollow noreferrer">Handling Errors Gracefully in Craft CMS</a> article, if it helps.</p>

CC BY-SA 4.0
2018-09-19T08:13:48.963Z
Thanks for the reply - had a look through the article and I'm afraid the `actionRenderError()` is not being called. As you can see from my stack trace it's the `actionRender()` method I am stuck inside, and not being able to handle the `NotFoundHttpException` thrown inside there
Mike F
CC BY-SA 4.0
2018-09-18T19:21:04.340Z
2018-09-18T19:21:04.340Z
andrew.welch
<p>Take a look in your general.php config file and see if you're overwriting the <code>errorTemplatePrefix</code> setting. It might look something like:</p>

<p><code>'errorTemplatePrefix' =&gt; "_errors/"</code></p>

<p>So you might need to move the 404.html file into "/templates/_errors/" directory.</p>

<p>See <a href="https://docs.craftcms.com/v3/config/config-settings.html#errortemplateprefix" rel="nofollow noreferrer">docs v3</a> </p>

CC BY-SA 4.0
2018-09-18T14:02:40.590Z
Thanks for your answer - `errorTemplatePrefix` isn't being overridden in `config/general.php` though.
Mike F
CC BY-SA 4.0
2018-09-18T16:08:35.327Z
Also this is v3 btw
Mike F
CC BY-SA 4.0
2018-09-19T09:13:04.160Z
Just updated the link to v3 doc. I'd suggest making sure that Craft is definitely not running Devmode and to add the config in my answer a go and see if that makes a difference. Prefixing 404.html with a "_" or putting the 404.html in a "_errors/" directory follows best practice so the file can't be loaded when going to "exmaple.com/404.html" as this would result in returning a 200 response instead of 404.
Jamie Jenkins
CC BY-SA 4.0
2018-09-19T09:20:58.613Z
Have tried as you have suggested and no luck unfortunately. I have updated my question to include that I've got another, smaller Craft site where I have no `errorTemplatePrefix` config and the file `templates/404.html`, and the `devMode` toggle works as expected in the docs. I am starting to think it must be something in the database which is the issue?
Mike F
CC BY-SA 4.0
2018-09-19T09:24:01.547Z
Okay, I haven't seen a DB issue result in this kind of thing before but you never know. Are these two Craft sites running the same version? Also If there's not too many plugins on the site you could try disabling them on by one and see if that has any effect.
Jamie Jenkins
CC BY-SA 4.0
2018-09-19T09:32:10.297Z
Both are running 3.0.25, and I've disabled every single plugin - still getting the same as originally described :(
Mike F
CC BY-SA 4.0
2018-09-18T13:57:07.267Z
2018-09-19T09:06:21.183Z
2018-09-19T09:06:21.183Z
Jamie Jenkins
<p>Having a strange issue - <code>devMode</code> is set to <code>false</code>, if I go to <code>/404</code>, I get the custom 404 page, which is great.</p>

<p>If I go to <code>/something1234567890</code> (which is definitely not an entry's URL) I get the following exception:</p>

<pre><code>yii\web\NotFoundHttpException: Template not found: something1234567890
</code></pre>

<p>I have tried adding debugging to my base templates but it looks like it is not getting as far as them.</p>

<p>Does anyone have an idea where I can start trying to debug this?</p>

<p><strong>Stack trace:</strong></p>

<pre><code>2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][yii\web\Application::handleRequest] Route requested: 'templates/render'
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][yii\base\Controller::runAction] Route to run: templates/render
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][yii\base\InlineAction::runWithParams] Running action: craft\controllers\TemplatesController::actionRender()
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][nystudio107\seomatic\{closure}] ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][error][yii\web\HttpException:404] yii\web\NotFoundHttpException: Template not found: something1234567890 in /home/vagrant/code/craft-site/vendor/craftcms/cms/src/controllers/TemplatesController.php:70
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][error][yii\web\HttpException:404] yii\web\NotFoundHttpException: Template not found: something1234567890 in /home/vagrant/code/craft-site/vendor/craftcms/cms/src/controllers/TemplatesController.php:70
Stack trace:
#0 [internal function]: craft\controllers\TemplatesController-&gt;actionRender('something123456...', Array)
#1 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction-&gt;runWithParams(Array)
#3 /home/vagrant/code/craft-site/vendor/craftcms/cms/src/web/Controller.php(103): yii\base\Controller-&gt;runAction('render', Array)
#4 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller-&gt;runAction('render', Array)
#5 /home/vagrant/code/craft-site/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module-&gt;runAction('templates/rende...', Array)
#6 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application-&gt;runAction('templates/rende...', Array)
#7 /home/vagrant/code/craft-site/vendor/craftcms/cms/src/web/Application.php(271): yii\web\Application-&gt;handleRequest(Object(craft\web\Request))
#8 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application-&gt;handleRequest(Object(craft\web\Request))
#9 /home/vagrant/code/craft-site/public/index.php(22): yii\base\Application-&gt;run()
#10 {ma    in}
</code></pre>

<p><strong>Update 1</strong></p>

<p>The <code>devMode</code> toggling works on another Craft 3 site I have, just not this particular one. Maybe it is a database issue?</p>

<p><strong>Update 2</strong></p>

<p>I have tried this codebase with a fresh database and still getting the same error, so it must be something to do with my codebase?</p>

<templating><craft3><404><error-templates>
Template not found 404
# Template not found 404

(Asked by: username_0 on 2018-09-18)

Having a strange issue - devMode is set to false, if I go to /404, I get the custom 404 page, which is great.
If I go to /something1234567890 (which is definitely not an entry's URL) I get the following exception:
yii\web\NotFoundHttpException: Template not found: something1234567890

I have tried adding debugging to my base templates but it looks like it is not getting as far as them.
Does anyone have an idea where I can start trying to debug this?
Stack trace:
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][yii\web\Application::handleRequest] Route requested: 'templates/render'
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][yii\base\Controller::runAction] Route to run: templates/render
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][yii\base\InlineAction::runWithParams] Running action: craft\controllers\TemplatesController::actionRender()
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][trace][nystudio107\seomatic\{closure}] ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][error][yii\web\HttpException:404] yii\web\NotFoundHttpException: Template not found: something1234567890 in /home/vagrant/code/craft-site/vendor/craftcms/cms/src/controllers/TemplatesController.php:70
2018-09-17 00:36:15 [xxx.xxx.xx.x][-][xxxxxxxxxxxxxxxxx][error][yii\web\HttpException:404] yii\web\NotFoundHttpException: Template not found: something1234567890 in /home/vagrant/code/craft-site/vendor/craftcms/cms/src/controllers/TemplatesController.php:70
Stack trace:
#0 [internal function]: craft\controllers\TemplatesController->actionRender('something123456...', Array)
#1 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#3 /home/vagrant/code/craft-site/vendor/craftcms/cms/src/web/Controller.php(103): yii\base\Controller->runAction('render', Array)
#4 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#5 /home/vagrant/code/craft-site/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module->runAction('templates/rende...', Array)
#6 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#7 /home/vagrant/code/craft-site/vendor/craftcms/cms/src/web/Application.php(271): yii\web\Application->handleRequest(Object(craft\web\Request))
#8 /home/vagrant/code/craft-site/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /home/vagrant/code/craft-site/public/index.php(22): yii\base\Application->run()
#10 {ma    in}

Update 1
The devMode toggling works on another Craft 3 site I have, just not this particular one. Maybe it is a database issue?
Update 2
I have tried this codebase with a fresh database and still getting the same error, so it must be something to do with my codebase?

**Tags:** templating, craft3, 404, error-templates

---

## 4 answers

### Answer by username_1 on 2018-09-19. Score: 4 | Accepted answer

Craft will serve one of 3 types of 404 errors.

When Dev Mode is enabled, you will get something like this, which shows the full stack trace leading up to the NotFoundHttpException:

[![enter image description here](https://i.sstatic.net/PAWnH.png)](https://i.sstatic.net/PAWnH.png)

If this looks like what you’re getting, then Dev Mode is *definitely* enabled. Double-check `config/general.php` for `devMode`, or `web/index.php` for `YII_DEBUG`.

Otherwise, you will get something like this in Craft’s Control Panel (as well as the front end if you haven’t specified a 404 template yet):

[![enter image description here](https://i.sstatic.net/qlvoL.png)](https://i.sstatic.net/qlvoL.png)

If it’s a front-end request, *and* you have a 404 template, then Craft will render your 404 template. If it encounters an error when trying to do that, a plain text error will be displayed, with no styling.

> **Comments:**
> **username_0**: `devMode` is set to `false` in `config/general.php` I swear! Is there any way to get Craft to dump what this value is before rendering the error to verify?  
> **username_1**: @MikeF Try going into your Control Panel - do you see the stripes in the top-left that indicate that Dev Mode is enabled?  
> **username_0**: Nothing there, still getting the same errors :(  
> **username_1**: OK, can you send a database backup, your `composer.json`, `composer.lock`, and config & template files over to support@craftcms.com, and tell us which URL you're getting this on? We can try reproducing it with those.  

---

### Answer by username_2 on 2020-01-31. Score: 4

If you've set devMode to `false` in your local environment and you *still* can't see your 404 template, go to your own user account in the CMS and uncheck "Show full exception views when Dev Mode is disabled".

[![enter image description here](https://i.sstatic.net/D4sxJ.png)](https://i.sstatic.net/D4sxJ.png)


---

### Answer by username_3 on 2018-09-18. Score: 3

There's a long discussion of all of this in the [Handling Errors Gracefully in Craft CMS](https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms#handling-exceptions-on-the-frontend) article, if it helps.

> **Comments:**
> **username_0**: Thanks for the reply - had a look through the article and I'm afraid the `actionRenderError()` is not being called. As you can see from my stack trace it's the `actionRender()` method I am stuck inside, and not being able to handle the `NotFoundHttpException` thrown inside there  

---

### Answer by username_4 on 2018-09-18. Score: 2

Take a look in your general.php config file and see if you're overwriting the `errorTemplatePrefix` setting. It might look something like:

`'errorTemplatePrefix' => "_errors/"`

So you might need to move the 404.html file into "/templates/\_errors/" directory.

See [docs v3](https://docs.craftcms.com/v3/config/config-settings.html#errortemplateprefix)

> **Comments:**
> **username_0**: Thanks for your answer - `errorTemplatePrefix` isn't being overridden in `config/general.php` though.  
> **username_0**: Also this is v3 btw  
> **username_4**: Just updated the link to v3 doc. I'd suggest making sure that Craft is definitely not running Devmode and to add the config in my answer a go and see if that makes a difference. Prefixing 404.html with a "_" or putting the 404.html in a "_errors/" directory follows best practice so the file can't be loaded when going to "exmaple.com/404.html" as this would result in returning a 200 response instead of 404.  
> **username_0**: Have tried as you have suggested and no luck unfortunately. I have updated my question to include that I've got another, smaller Craft site where I have no `errorTemplatePrefix` config and the file `templates/404.html`, and the `devMode` toggle works as expected in the docs. I am starting to think it must be something in the database which is the issue?  
> **username_4**: Okay, I haven't seen a DB issue result in this kind of thing before but you never know. Are these two Craft sites running the same version? Also If there's not too many plugins on the site you could try disabling them on by one and see if that has any effect.  
> **username_0**: Both are running 3.0.25, and I've disabled every single plugin - still getting the same as originally described :(  

---

