Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nievesandres's avatar

I get an error 419 every time I try to login or register a user in Laravel 8 hosting. What could it be?

I uploaded my laravel 8 project to hosting, it worked perfectly locally but hosting gives me this error. I use the forms that laravel provides for authentication so everyone has the @csrf directive, as well as verify that the storage folder has recursive permissions 777. The hosting has installed php 7.4

already run commands like: php artisan config: cache php artisan cache: clear php artisan key: generate php artisan view: clear php artisan optimize

And I still can't solve this error, it caught my attention is that the files that are created in the / storage / framework / session folder when trying to log in have 644 permissions. Besides, I also have another problem, the routes that are outside the middleware auth do not load but redirect me back to login. Comment the \ App \ Http \ Middleware \ VerifyCsrfToken :: class in Kernel.php and I pass the same when I start the session I am redirected again to the login view, so if there is any problem with the token but also with the routes, I have searched in many forums and so far I have not gotten a solution to this.

0 likes
6 replies
aschmelyun's avatar

@nievesandres It sounds like for some reason, the session cookies aren't being set, and that's why you're getting a 419 and getting redirected back to the login screen.

What browser are you using, and have you tried a different one? Is your site name in the .env file set to the correct domain that you're hosting this website on?

nievesandres's avatar

@aschmelyun use Chrome, Firefox and operates obtaining the same behavior. I created a subdomain in the hosting for the project, I have SESSION_DOMAIN configured with the subdomain, the whole project is in a folder and the subdomain points to the public folder of the project

Snapey's avatar

Is this an apache server?

There is a problem I've seen quite a few times when you have content sent out by your application prior to sending the session cookies.

1st step is to check to see if your browser receives cookies from the server

nievesandres's avatar

@Snapey If it is apache, in the browser settings it allows to receive cookies, try like this too and I got the same

Snapey's avatar

im asking IS it Apache ?

im asking do you receive cookies in the browser?

Im not asking you to change anything

redroseamit's avatar

please check with your .htacess file and .env try to make some correction. sometime lead same issue with wrong configuration inside .htaccess file .

Please or to participate in this conversation.