Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 6 Showed 419 | page expired

Tags:

laravel

In a local server the following laravel project working fine, But When the project upload on online server it's showing the problem.

When trying to login then its show:

419 | page expired.

I have cleared route, view, cache, and config when I uploaded it on online serve.

like image 346
Belal Khan Avatar asked Jan 30 '20 06:01

Belal Khan


1 Answers

This error occurs due to CSRF token verification failure, misconfigured cache, permissions, improper session settings. This error shows up when a user submits a post request. You can fix it by doing belows:

  1. CSRF token verification failure The most common reason for the 419 error is CSRF token failure. Cross-site request forgery is a unique, encrypted value generated by the server. This is included in the HTTP request of the client. Later the server verifies it. If this fails, it leads to session expired error. So, you check the CSRF setting in the Laravel config.

  2. Session expired error due to cache Sometimes, the cache can also lead to session expired error in front-end. This can be both the server cache and browser cache. So, clear the server cache using php artisan cache:clear.

  3. Laravel file and folder permissions Similarly, improper file or folder permission can also lead to errors. Usually, web servers need write-permissions on the Laravel folders storage and vendor. Also, session storage needs write-permission. So, give permissions as,

chmod -R 755 storage

chmod -R 755 vendor

chmod -R 644 bootstrap/caches
  1. Laravel session setting Last but not least, session settings can also cause a 419 error. The app/config/session.php is the session config file. Check for a few important parameters – domain and secure.
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false), // in case of cookie

These step by step approach fixes the error and make Laravel working again.

like image 153
Farhod Nematov Avatar answered Oct 13 '22 11:10

Farhod Nematov