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

parvezmrobin's avatar

Suddenly verification of CSRF token failed

Last night I ran my project. It was well enough. Then I went to sleep. No one touched my PC. I woke up. Ran the project again. And bingo! TokenMismatchException in VerifyCsrfToken.php

I've faced this kinda problem before too.i didn't touched login or registration page. But suddenly they start showing this kinda error.

Can anyone provide any solve our at least the reason why it's happening?

0 likes
9 replies
Paschal's avatar

That's weird. If you are using Blade templating, do confirm you have this inside the form {{ csrf_field() }}. Make sure it is in between the HTML form tags. It can be anywhere `

mstnorris's avatar

Have you upgraded your Laravel application at all?

Since version 5.2 (correct me if I am wrong on the version) but the CSRF Middleware is added automatically to the web routes and therefore it is added twice; and I remember back then that it caused those issues.

Please provide what version of Laravel you're using and also your routes file, and the route that you're hitting that is causing the problem so we may assist you further.

sl0wik's avatar

It might happen if you are using php artisan serve instead solid web server (like apache or nginx).

parvezmrobin's avatar

@paschal @mstnorris It was working properly last night. So I don't think it's a syntax or similar error. Can this be caused by cache or something else?

sl0wik's avatar

I had problems with authentication + php artisan serve various times, a specially while running more than one project on localhost.

Install some solid web server like:

parvezmrobin's avatar

@leber I have xampp on my PC but no idea how to run Laravel app from there. Can you provide me any resource?

nikocraft's avatar

Just put it here

C:\xampp\htdocs\laravel-project

edit C:\Windows\System32\Drivers\etc\hosts

add 127.0.0.1 laravel-project.dev

open C:\xampp\apache\conf\extra\httpd-vhosts.conf

and add

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/laravel-project/public"
    ServerName laravel-project.dev
</VirtualHost>

restart apache and you are ready to go

1 like
korneliuskristianr's avatar

I was experienced it, it happened to me because i've opened 2 different login page in same time

Please or to participate in this conversation.