419 Page Expired in Laravel: why the token did not match
A 419 almost never means the form forgot its token. Far more often the session that holds the token never arrived with the request. Here is how the check works, the six usual causes in order, and why you will not find a 419 in laravel.log.
A user fills in a form, presses submit, and gets 419 | Page Expired. It works on your machine. In
production it happens to some users, some of the time. The name suggests a form left open too long, and that is
one cause, but far more often the session the token belongs to simply never arrived with the request.
What does 419 Page Expired mean?
It means Laravel's CSRF protection rejected the request. When a page with a form loads, Laravel stores a random
token in the visitor's session and puts the same token in the form, through the @csrf directive. When
the form is posted, Laravel reads the token from the request, either the hidden _token field or an
X-CSRF-TOKEN or X-XSRF-TOKEN header, and compares it with the one in the session. If they
differ, it throws a token mismatch and answers with status 419.
The comparison needs two things: the token in the request and the session on the server. The session is found through a cookie. If that cookie is not sent back, Laravel starts a brand new, empty session for the request, and no token could ever match it.
How do you tell a bad form from a lost session?
Open the browser's developer tools, load the form, and check the Application or Storage tab for the session cookie.
Its name comes from your app name, so an app called Laravel uses laravel_session. Then
submit the form with the Network tab open and look at the request:
- The request has no session cookie. The browser never stored it or refused to send it. This is a cookie configuration problem, and the form is fine.
- The cookie is there but the response sets a new one. The server could not find that session: it expired, it lives on another server, or the session store failed.
- The cookie is there and stable, but the request has no
_token. Now it really is the form, or the JavaScript sending it.
Developer tools also flag cookies the browser rejected. A small warning icon on the Set-Cookie header
of the form page usually explains the whole problem.
What causes a 419, in order?
1. A secure cookie on plain HTTP. With SESSION_SECURE_COOKIE=true, the browser only
sends the cookie over HTTPS. Test the site over http://, or run it behind a proxy that Laravel does not
trust as HTTPS, and every post fails.
2. The wrong cookie domain. A SESSION_DOMAIN left over from staging, or set to a
domain the site is not actually served from, makes the browser refuse or misplace the cookie. When in doubt, leave
it empty so the cookie belongs to the current host.
3. Sessions that are not shared between servers. The file session driver keeps
sessions on one server's disk. Behind a load balancer, the form loads on one server and posts to another that has
never heard of the session. Use the database or redis driver on any app with more than one
server.
4. A cached page with an old token. A full-page cache, such as a CDN rule that caches HTML, serves every visitor the same form with the same token, which matches nobody's session. Do not cache pages that contain forms, or load the token separately.
5. The session really expired. SESSION_LIFETIME defaults to 120 minutes. A form
left open in a tab over lunch has a token for a session that is gone. This is the only cause the name of the error
actually describes.
6. The form or request is missing the token. A form without @csrf, or a JavaScript
request that sends neither the field nor a header. Laravel's default Axios setup sends the
X-XSRF-TOKEN header automatically on same-origin requests, so this mostly affects custom
fetch calls and forms built outside Blade.
What about webhooks and payment callbacks?
Requests from other services, such as a payment provider posting a callback, can never carry your CSRF token, so
those routes must be excluded from the check. Since Laravel 11, list them in bootstrap/app.php:
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(except: [
'stripe/*',
]);
})
Older versions use the $except array in app/Http/Middleware/VerifyCsrfToken.php. Put
webhook routes in routes/api.php where possible, since the API routes do not use the CSRF middleware at
all, and verify each provider's signature in the handler.
Why is the 419 not in laravel.log?
Because Laravel deliberately does not report token mismatches. They are listed among the exceptions its handler skips, alongside validation failures and 404s, since most of them are users with an old tab rather than bugs. That is sensible for noise and unhelpful when a misconfiguration is rejecting every login. If you suspect one, log them yourself for a few days: the route, whether the session cookie arrived, and whether the request was secure. A pattern appears quickly.
To make the remaining genuine expiries less jarring, add a
resources/views/errors/419.blade.php view. Laravel uses it instead of the default page, and it can
tell users plainly to reload and try again.
For the errors a Laravel deploy throws before anyone gets as far as a form, see Laravel 500 error after deploy.
Found something wrong in here? Tell me.