Error message

Laravel: 419 Page Expired, CSRF token mismatch

Laravel answers a form submission with a 419 “Page Expired” page, or {"message": "CSRF token mismatch."} for an API call. Nobody gets an alert: Laravel does not report this exception, so sentry/sentry-laravel never sees it. That is deliberate, and you can change it with one line.

Updated

Examples run on 21 November 2026 with Laravel 13.43.0, PHP 8.6.0 and sentry/sentry-laravel 4.22.0, 4.26.0 and 4.31.0. Errilo is in private beta.

What the message says

In Laravel 13.43.0, the PreventRequestForgery middleware checks every POST, PUT, PATCH and DELETE request of the web group (it was called VerifyCsrfToken before Laravel 13). When it can’t validate the request, it throws Illuminate\Session\TokenMismatchException (CSRF token mismatch.), which Laravel turns into an HTTP error 419. A form and its route:

routes/web.php
Route::get('/form', fn () => '<form method="POST" action="/form">
    <input type="hidden" name="_token" value="'.csrf_token().'"><button>Save</button></form>');
Route::post('/form', fn () => 'saved');

A POST without token, with APP_DEBUG=false:

$ curl -s -o /dev/null -w "HTTP %{http_code}
" -X POST http://127.0.0.1:8000/form
HTTP 419            (HTML page titled "Page Expired")

$ curl -H 'Accept: application/json' -X POST http://127.0.0.1:8000/form
{"message": "CSRF token mismatch."}   (HTTP 419)

The middleware lets the request through when one of these holds, read in its source and run:

Causes and fixes

For fetch and Ajax, send the token in the header:

layout.blade.php
<meta name="csrf-token" content="{{ csrf_token() }}">
<script>
  fetch('/form', {
    method: 'POST',
    headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name=csrf-token]').content },
  });
</script>

Why Sentry does not report it

Integration::handles($exceptions) registers a reportable callback on Laravel’s exception handler, and Laravel only calls those for exceptions it would report. Its list of internal exceptions that are never reported ($internalDontReport in Handler.php) includes TokenMismatchException, and also HttpException (every 4xx), AuthenticationException, ValidationException and ModelNotFoundException.

We checked it with the three versions of sentry/sentry-laravel. In one run, a route that threw Class "…" not found returned 500 and arrived in the fake ingest; a POST without token returned 419 and nothing arrived. So the 419s your users see are invisible to an error tracker, unless you ask for them:

bootstrap/app.php (excerpt)
use Illuminate\Session\TokenMismatchException;
use Sentry\Laravel\Integration;

->withExceptions(function (Exceptions $exceptions) {
    Integration::handles($exceptions);
    $exceptions->stopIgnoring(TokenMismatchException::class);
})

The setup is in the Laravel guide. Symfony has its own CSRF component; we did not test it, see the Symfony guide for the setup.

How Errilo shows it

Once you report it, the issue is titled Illuminate\Session\TokenMismatchException: CSRF token mismatch., with an Unhandled badge and level Error (the event has none, and Errilo reads that as an error). Its location is require_once in public/index.php: the failure happens in a middleware of the framework, before any of your code, so the top frame of your own code is the entry point.

Errilo groups on the type and the frames. In our test, the same failure on POST /form and POST /other had the same fingerprint: one issue for every 419 in the application. The request of each event tells the routes apart. Without stopIgnoring(), Errilo shows nothing, because the SDK sends nothing: Errilo has no filter to apply and no event to filter.

Early access

The private beta is open, by invitation, to a handful of teams running a JavaScript, TypeScript, PHP or Python app in production. Join the waitlist and we’ll write to invite you.