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

haydi80's avatar

Cannot login to my live application, no logs on laravel.log

Hello,

I developed a Laravel application with login page, I am using Laravel 5.4. Locally everything works fine. After deploying, my DB connection in the env file looks like that:

APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=myapp.nl

DB_CONNECTION=mysql DB_HOST=db_host_name.nl DB_PORT=3306 DB_DATABASE=db_name DB_USERNAME=user_name DB_PASSWORD=password

When I open myapp.nl, I get the login page, I fill in the login and password (that already exist on users table on my db_name). After that, the login and password fields get directly empty, I fill them in again, then I get:

Whoops, looks like something went wrong.

(1/1) TokenMismatchException in VerifyCsrfToken.php line 68

And nothing is logged into storage/logs/laravel.log

I hope you can help me get it work.. Thanks in advance!

0 likes
11 replies
Sergiu17's avatar

Hi, TokenMismatchException means that token is missing, do you have APP_KEY in your .env file?

also make sure you have write permission to the storage folder: sudo chmod -R 755 /storage

and try again

haydi80's avatar

Hi Sergiu17. Yes I do have write permission. Actually when the database configuration was not good, I got error messages in my laravel.log, like:

production.ERROR: PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from users where username = Admin limit 1)

SQLSTATE[HY000] [1045] Access denied for user ...

Now the configuration seems to be ok, but may be the APP_KEY is not good. I have the APP_KEY in my .env file, this one I got it when I run artisan key:generate locally, because I don't have ssh on my server. Me too I have doubts about this APP_KEY, but how can I correct it if it's wrong? Thank you

haydi80's avatar

Just one update.. I tried to omit the user authentication in the login page, and go directly to the dashboard page, the dashboard appears correctly, I navigated to another page and created a new user, this user was correctly saved into the users table in the remote database.. It is a problem of authentication then. Can it be that the middleware doesn't work? But that is exactly as what works fine locally!

munazzil's avatar

Then it could be cache problem try with below command,

  php artisan cache:clear
  php artisan view:clear
  php artisan route:clear
haydi80's avatar

Thank you.. I did it, but it still doesn't work!

Normally, after I fill in the username and password, I should get in the login function of Illuminate\Foundation\Auth\AuthenticatesUsers, right? But I don't get in !!

munazzil's avatar

Have you change config/app.php as like following ,

 'env' => env('APP_ENV', 'production'),

and run

     php artisan up
haydi80's avatar

I have already :

'env' => env('APP_ENV', 'production'),

But I didn't run php artisan up

I have actually no ssh on my server. The clear commands I included them in web.php like that:

Route::get('/clear-cache', function() { Artisan::call('cache:clear'); Artisan::call('view:clear'); Artisan::call('route:clear'); return "Cache is cleared"; });

Then I call: myapp/clear-cach

siangboon's avatar

Try use IP address instead of hostname for the DB_HOST

haydi80's avatar

Thank you guys..

Even with address IP I cannot login..

Actually the DB_HOST worked fine when I omitted the login page, and I could create a new user and save it in DB, as I said.. The problem lies on the authentication, the login function should be visited while it's not the case

Jaytee's avatar

TokenMismatchExceptions are usually thrown when you don't have a csrf token in your form. Check your authentication forms and make sure they're including a csrf token.

haydi80's avatar

I do have csrf token in my form like that:

{{ csrf_field() }}

Now after I deleted the handle function from the VerifyCsrfToken.php, the first time when I fill the login, the fileds become empty, and the second time after I fill them again, I get:

Whoops, looks like something went wrong.

No TokenMismatchException any more..

But still the aithentication doesn't work!!

Please or to participate in this conversation.