I'm having a problem since I'm new to Magento.

how can I create a custom error pages in my Magento 2 site?

For example these pages: 500, 401, 403, and 404. I hope someone can help me.



1 Answer 1


you can customize (404) page from admin

Content->Pages->404 Not Found->Edit->content

here you can change whatever content you need.

If you look programmatically solution, add the below content in your <root-magent>/app/code/Vendor/Module/etc/di.xml

<type name="Magento\Framework\App\Router\NoRouteHandlerList">
    <argument name="handlerClassesList" xsi:type="array">
        <item name="default" xsi:type="array">
            <item name="class"
            <item name="sortOrder" xsi:type="string">200</item>

add this content in above mentioned controller

namespace Vendor\Module\Controller;
class NoRouteHandler implements \Magento\Framework\App\Router\NoRouteHandlerInterface {

    public function process(\Magento\Framework\App\RequestInterface $request) {
        $moduleName= 'cms';
        $controllerName = 'index';
        $actionName= 'index';

        return true;

In this controller you can set whatever module/controller/actionname for 404 page.

follow this link to set 401,403,500 page

  • Hi bro thanks for this wonderful answer!!! Thank you for helping me :) Sep 2, 2016 at 8:47

Your Answer

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

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