Laravel: Custom error pages not working (404 not found, 500 error)


I want to create an custom error page for: 404 Not found and 500 Error status codes in Laravel. I want to style those pages in our CI design. It seems like there is a function included in the Laravel kernel but I cant make it work. Could someone guide me please? 

Programming Question created: 2020-08-15 07:08 zulu


You need to make a small adjustment on your application to make the custom error pages work in Laravel. Laravel uses the internal error pages by default if you don't modify the exception handler. The following solution will work for Laravel 5.x, Laravel 6.x and so on..

Enabling custom error pages in Laravel:

1) You need to generate the error pages blade view files in your project. You can do this by using this command. It will generate the blade error view files in your ressources view directory:

php artisan vendor:publish --tag=laravel-errors

2) Modify the the exception handler to make Laravel load your custom blade error templates. The file is located here: app/Exceptions/Handler.php.

 * Render an exception
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $exception
 * @return \Symfony\Component\HttpFoundation\Response
 * @throws \Exception
public function render($request, Exception $exception)
    if ($this->isHttpException($exception)) {
        return $this->renderHttpException($exception);
    } else {
        return parent::render($request, $exception);
answered 2020-08-18 07:51 Zunami