How To Solve The Page Expired 419 Error In Laravel

In this tutorial, I'll provide you with a solution to the "419 Page Expired" error in Laravel. This error, often displayed as "The page has expired due to inactivity. Please refresh and try again," is typically caused by the csrf_token.

To help you resolve this issue, I've included an example for diagnosing and addressing it based on your specific requirements.

Discover practical examples and step-by-step guidance to overcome the common "419 Page Expired" error in Laravel 8, Laravel 9, and Laravel 10.

Example 1:

If you are getting an error after submitting the form in laravel then you need to add the CSRF field in your form like below.

<form method="POST" action="/test">


Example 2:

 If you are getting an error after AJAX  call then you need to add a header like below in meta tag.

In your head tag.

<meta name="csrf-token" content="{{ csrf_token() }}">

And after that you need to add below code in your script tag.

    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

In some conditions also happen Cache issue, So, we need to clear it.

For clearing Cache, View, Routes in Laravel check below.


You may also like:


Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.