Laravel TokenMismatchError in Production (Login)

66 views Asked by At

I just updated ubuntu packages and composer update from inside my ssh terminal on Forge

Now when I try to login I get TokenMismatchException in VerifyCsrfToken.php (line 68)

I have tried

  • deleted browsers cookies and application data
  • php artisan clear:cache
  • composer dump-autoload
  • Deleted composer.lock on both sides, updated from homestead and git push to server
  • php artisan clear-compiled
  • Restarted Nginx, Server

I am running out of ideas now. What can I do to fix this??

Thanks

2

There are 2 answers

0
mbozwood On

After discussion, it was a folder permissions issues.

chmod 777 -R storage

OP must be careful with this as it opens up the server.

More appropriate for production would be the following: sudo chgrp -R www-data storage bootstrap/cache sudo chmod -R ug+rwx storage bootstrap/cache

0
Dazzle On

chmod 777 -R storage was enough to enable log in, but it brought other issues. Users could not post images for example.

This is eventually what worked for me -

ssh

Check if forge is set as the user $ ps -aux | grep "php"

if you get www-data instead of forge, you might have the same problem as me and need to set forge as the user instead of www-data

$ sudo chown -R forge:www-data /home/forge/mysite.com

$ sudo chmod -R 770 /home/forge/mysite.com

Everything works as expected for me again

Back to pretending like I know what I'm doing!! :D