419 Page Expired

Failed CSRF token validation in the Laravel PHP Framework produces the unofficial 419 Page Expired status code. An IETF draft now proposes the same number for 419 Purpose Declined, a refusal of a prefetch or prerender request.

Usage

The 419 Page Expired error created by the Laravel PHP Framework is received when CSRF validation fails. This implies CSRF protection is turned on, and Laravel enables CSRF protection by default for all POST, PUT, PATCH, and DELETE requests.

Example

The client attempts to send a file and the server responds with 419 Page Expired to indicate CSRF validation failed.

Request

PUT / HTTP/1.1
Host: www.example.re
Content-Type: application/pdf
Content-Length: 10000

<10000 bytes of PDF data>

Response

HTTP/1.1 419 Page Expired
Content-Type: text/html
Content-Length: 146

<html>
  <head>
    <title>Page Expired</title>
  </head>
  <body>
   <p>The session has expired. Refresh and try again.
   </p>
  </body>
</html>

How to fix

Missing CSRF token in forms. Every form submitting POST, PUT, PATCH, or DELETE requests needs the @csrf Blade directive. This generates a hidden input field containing the CSRF token. Without the directive, Laravel rejects the request with 419.

Expired session. The CSRF token is tied to the user session. When the session expires, the token becomes invalid. Refreshing the page generates a fresh session and token. Extend the session lifetime in config/session.php by increasing the lifetime value (in minutes) when users need longer form submission windows.

AJAX and API requests. Include the token as an X-CSRF-TOKEN header. The common pattern adds a meta tag <meta name="csrf-token"> to the page layout, then reads the value in JavaScript. For cookie-based sessions with JavaScript frameworks, Laravel sets an XSRF-TOKEN cookie. Axios and similar libraries read this cookie and send the X-XSRF-TOKEN header automatically.

Session storage issues. When using the file session driver, verify the storage/framework/sessions directory exists and the web server process has write permissions. Give the directory to the web server user, for example chown -R www-data:www-data storage, since permission bits alone grant nothing to a process running as a different user. For database or redis drivers, confirm the connection is stable and the sessions table or Redis instance is accessible.

Multi-domain and load balancer setups. The session cookie domain and the SESSION_DOMAIN environment variable must match the application domain. Behind a load balancer, sticky sessions or a shared session store (database or Redis) prevent requests from hitting a different server with no knowledge of the original session.

API-only routes. Routes handling stateless API traffic do not need CSRF protection. Routes in the api group are excluded by default. Current Laravel releases exclude specific web routes by listing them in validateCsrfTokens(except: [...]) within the withMiddleware closure in bootstrap/app.php. Older releases use the $except array in the VerifyCsrfToken middleware class.

419 Purpose Declined

An IETF draft defines 419 Purpose Declined as the answer to a request refused because of its declared purpose. Browsers declare a prefetch or prerender through the Sec-Purpose request header, and an origin or CDN unwilling to serve speculative requests answers 419 instead of a 503, which operators otherwise misread as an outage in their dashboards.

The draft sets a few rules. The refusal applies to the one request, so a later request with the same purpose may succeed. The response is never shown to a user, so it should carry no content and any content is discarded. Origins and gateways acting for them, such as CDNs and reverse proxies, may generate the code, while forward proxies should not. The response is not heuristically cacheable and should be marked uncacheable, so a cache never reuses the refusal for a normal navigation.

The number collides with Laravel's use. Both are unofficial until the registry lists the draft's entry, and the two never meet in practice: Laravel sends 419 after a failed CSRF check on a form submission, while the draft covers speculative fetches triggered by speculation rules. A client reading the status alone cannot tell them apart, so Laravel applications and speculation-aware CDNs each rely on their own context.

See also

Last updated: November 3, 2026