1 year ago

419 error when submitting form in production - Sorry, your session has expired. Please refresh and try again

Posted 1 year ago by connor11528

I've got a Laravel 5.7 app that is working locally. For instance, when running locally I'll get flash messages about failed validation and it shows fine in the blade view:

I do have the @csrf helper in my blade form.

When I deploy and submit the form on production I get a 419 error: "Sorry, your session has expired. Please refresh and try again". Redirects are not working for social login with google or linkedin in production, though they're working locally.

I am using Laravel Forge for production and database tables for session and cache. So my .env file for production is:


I have tried changing the APP_NAME and APP_KEY and deleting all the contents of the "sessions" table as well but the 419 error persists on production.

Then my deployment script for Laravel Forge is:

cd /home/forge/
git reset --hard origin/master
git pull origin master
composer install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader
echo "" | sudo -S service php7.2-fpm reload
rm -rf node_modules
composer dump-autoload
php artisan config:clear
php artisan view:clear
php artisan responsecache:clear
php artisan config:cache
php artisan migrate --force
php artisan sitemap:generate 

How can I clear the sessions so I don't get the 419 "your session has expired" and the form works on the production server?

Please sign in or create an account to participate in this conversation.