Laravel Tutorials

How to Create Custom 404 Page in Laravel 9 Application

Through this Laravel tutorial, we would like to share with you how to easily create a custom error page 404 and 403, 500, 419, 255, 405 error pages in the Laravel application.

While working on a web application errors or more precisely exception can manifest at any time, Laravel framework handles exceptions beautifully.

It offers a handy error handler class which looks for almost every errors displayed in Laravel environment and returns an adequate response.

Generically, you can get the default error response if you configure debug property to false; nevertheless, you can create a custom error handling template.

Let’s handle custom errors in Laravel.

Create New Laravel Project

Start this tutorial by creating a brand new Laravel project using the following command:

composer create-project laravel/laravel --prefer-dist laravel-error-handling-example

Create Custom 404 Error Page

You need to create blade views for error pages, move to this path resources/views/ inside here create errors folder and within the directory create 404.blade.php file. It will redirect you to the 404 page if you don’t find the associated URL.

Similarly you can create rest of the error handling blade views for 403, 500, 419, 255 and 405 exceptions:

Include the following code in resources/views/errors/404.blade.php error file.

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>404 Custom Error Page Example</title>
    <link rel="stylesheet" href="">


    <div class="container mt-5 pt-5">
        <div class="alert alert-danger text-center">
            <h2 class="display-3">404</h2>
            <p class="display-5">Oops! Something is wrong.</p>


To test out the 404 custom error template, you need to start the application.

php artisan serve

As you know, 404 errors occur when you visit the non-existed link, so type the wrong URL in the browser’s address bar.

Easy, isn’t it. This tutorial is over, i hope you liked it.


I am Digamber, a full-stack developer and fitness aficionado. I created this site to bestow my coding experience with newbie programmers. I love to write on JavaScript, ECMAScript, React, Angular, Vue, Laravel.

Recent Posts

React Redux Handle API Calls with Thunk Middleware Tutorial

In this post, we will learn how to work with HTTP requests in the Redux…

1 day ago

Node AJAX Retrieve Records from MySQL Database Tutorial

MySQL is a relational database management system based on SQL – Structured Query Language, and…

4 days ago

React Manage REST API State Globally with Context API Tutorial

React Js Handle Rest API data globally with Context and useState hook tutorial. In this…

1 week ago

How to Delete Data from MySQL Database using Node Js

Node js delete data from MySQL database tutorial; Throughout this guide, you will ascertain how…

1 week ago

Node Import CSV File Data to MySQL Database with HTML Form

In this tutorial, you will discover how to import CSV file into MySQL database using…

2 weeks ago

How to Handle Global State in React js using Context API

React Js Global state management with createContext hook example; In this tutorial, we will help…

2 weeks ago