# 419 Page Expired

Laravel refused a form or request because its CSRF token was missing or did not match the session. Send the token and make sure the session cookie comes back.

Message:

```text
CSRF token mismatch.
```

Exception:

```text
Illuminate\Session\TokenMismatchException
```

## What it means

The `PreventRequestForgery` middleware in the `web` middleware group checks every request except `GET`, `HEAD` and `OPTIONS`. When a request cannot show that it came from your own pages, the middleware throws `TokenMismatchException` with the message "CSRF token mismatch." and Laravel answers with status 419. A browser gets a page titled "Page Expired". A request that asks for JSON gets `{"message": "CSRF token mismatch."}`.

A request passes in one of two ways. A browser that sends the header `Sec-Fetch-Site: same-origin` is let through without a token, and browsers send that header only to secure origins: HTTPS, or localhost. Every other request needs a token that matches the one in the visitor's session, sent as the `_token` form field or in an `X-CSRF-TOKEN` or `X-XSRF-TOKEN` header.

## Why it happens

- The form has no `@csrf` field. Over HTTPS a current browser passes the origin check without it, so the form can work in production and fail over plain HTTP on a real host name or in an older browser.
- The session ended while the page sat open. The token in the form belongs to a session that is gone. `SESSION_LIFETIME` sets how long an idle session lives, 120 minutes by default.
- The session cookie never comes back. A `SESSION_DOMAIN` that does not cover the host, `SESSION_SECURE_COOKIE=true` on a site served over plain HTTP, or a `same_site` value the request does not meet keeps the browser from sending the cookie. Laravel then starts a new session on every request, with a new token.
- A cached page serves an old token. A full-page cache or a CDN that stores the HTML hands every visitor the token of the session it was cached under.
- A JavaScript request sends no token and fails the origin check, because it runs over plain HTTP or comes from another origin. A same-origin `fetch` over HTTPS passes without a token. Axios copies the `XSRF-TOKEN` cookie into the `X-XSRF-TOKEN` header on same-origin requests by itself.
- The request comes from another site or subdomain, such as a payment page posting back. Its `Sec-Fetch-Site` is `cross-site` or `same-site`, so it does not pass the origin check by default, and it carries no token for your session.

## How to fix it

Put the token in every form that changes something:

```blade
<form method="POST" action="/profile">
    @csrf
    <!-- fields -->
</form>
```

For JavaScript, print the token in the page and send it as a header:

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

```js
const form = document.querySelector('#profile-form');

fetch('/profile', {
    method: 'POST',
    headers: {
        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
    },
    body: new FormData(form),
});
```

Then check the cookie: in the browser's developer tools, the request should carry the session cookie, named by `SESSION_COOKIE` or else your snake-cased app name followed by `_session`, `laravel_session` by default. If it is missing, correct `SESSION_DOMAIN`, `SESSION_SECURE_COOKIE` or `SESSION_SAME_SITE`. Keep pages with forms out of any full-page cache.

A route that another service posts to, such as a payment webhook, cannot know the token. Exclude it in the `withMiddleware` closure of `bootstrap/app.php`:

```php
$middleware->preventRequestForgery(except: [
    'stripe/*',
]);
```

## Find it in production

Laravel does not report this exception. `TokenMismatchException` is on the `$internalDontReport` list in `Illuminate\Foundation\Exceptions\Handler`, so it is never logged and never reaches an error tracker that hooks into the exception handler, Ranetrace's [error monitoring](/features/error-monitoring) included. A visitor who loses a form to it leaves nothing in your error list.

The trace is in the web server's access log: `POST` requests answered with status 419, each with the path of the form that failed.

To have Laravel report it like any other exception, stop ignoring it in the `withExceptions` closure of `bootstrap/app.php`:

```php
$exceptions->stopIgnoring(\Illuminate\Session\TokenMismatchException::class);
```

Each mismatch is then logged and passed to the error trackers hooked into the handler, Ranetrace included.

Reproduced on Laravel 13.45, PHP 8.5, 5 December 2026.

Read more: https://laravel.com/docs/csrf

## Related

### Terms

- [Middleware in Laravel](https://ranetrace.com/glossary/middleware-in-laravel.md)
- [Middleware groups in Laravel](https://ranetrace.com/glossary/middleware-groups-in-laravel.md)
- [HTTP status code](https://ranetrace.com/glossary/http-status-code.md)

### Other errors

- [The GET method is not supported for route](https://ranetrace.com/error-guides/laravel-method-not-supported-for-route.md)
- [No application encryption key has been specified](https://ranetrace.com/error-guides/laravel-no-application-encryption-key.md)
- [429 Too Many Requests](https://ranetrace.com/error-guides/laravel-429-too-many-requests.md)

Read this guide in a browser: https://ranetrace.com/error-guides/laravel-419-page-expired
