vincent15000's avatar

VPS / Manual installation / Laravel, InertiaJS, VueJS

Hello,

I have installed Ubuntu 24.04 on a virtual machine on VirtualBox to test an installation / deployment scenario.

All works fine.

So I have used the same scenario on a VPS prepared with Ubuntu 24.04. I have installed all what is needed, exactly like on the virtual machnine.

All works fine except actions on the database.

I explain :

  • I can run a console command to seed the database, it creates an admin user, he receives an email to reset his password, it works fine

  • when I click on the button received in the reset password email, it redirects me to the reset password page, I type my email and the new password (twice), I get no error, but the action isn't done, the password isn't reset

  • so I have tried to go directly to the reset password page, I type my email, I don't receive any email to reset my password

  • all this works fine on the virtual machine, but not on the VPS

I have thought it could be a problem with the token which is valid on for some time, so I checked the timezone, all seems to be ok.

What do you suggest me to check ?

Thanks for your help.

V

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! Based on your description, here are possible causes and a checklist to help debug your issue where database actions (like password reset via InertiaJS and VueJS) work on your local VM, but not on your VPS:


1. Database Connection Configuration

Double-check your .env file on the VPS. Maybe the database config is slightly off, or user privileges are bad.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_db_name
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password

Tip: Test DB connection via CLI:

php artisan tinker

>>> \DB::connection()->getPdo();

2. File Permissions & Cache

File/dir permissions can be different on VPS and block some Laravel operations (e.g., writing cache, session, etc.).

sudo chown -R www-data:www-data /path/to/your-project
sudo chmod -R 755 /path/to/your-project/storage
sudo chmod -R 755 /path/to/your-project/bootstrap/cache

Clear config, route, and cache:

php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan cache:clear

3. Server Timezone

You've checked timezone, but try dumping/echoing the server time in a controller to compare with your expected time.

public function testTime() {
    return now();
}

4. Email Configuration

You said email works for the first reset, but fails in the second case. Double-check your mail config (.env):

MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=...
MAIL_USERNAME=...
MAIL_PASSWORD=...
MAIL_ENCRYPTION=...
MAIL_FROM_ADDRESS=...
MAIL_FROM_NAME="Your App"

Check mail logs/queue for failed emails.


5. SESSION/CSRF Issues

On VPS, check that your app url and session domain are set correctly. If you're using HTTPS, ensure that's consistent.

APP_URL=https://your-vps-domain.com
SESSION_DOMAIN=your-vps-domain.com
SESSION_SECURE_COOKIE=true

Try setting APP_DEBUG=true temporarily to see more errors.


6. Queue Driver

Password reset and other emails may be queued. Ensure your queue worker is running on the VPS:

php artisan queue:work

If you use sync as queue driver, consider database or redis for production.


7. Database Permissions

Test updating a user via tinker:

php artisan tinker

>>> $user = \App\Models\User::find(1);
>>> $user->password = bcrypt('newpassword');
>>> $user->save();

Does this save to the DB on your VPS? If not, your DB user may lack UPDATE permissions.


8. Web Server Error Logs

Check your web server (Nginx/Apache) error logs. Maybe there is a 500 error not shown in the browser.


9. .env Caching

If your .env file is edited, you must clear the config cache:

php artisan config:cache

10. Debugging with Logs

Add logging to your password reset controller to see if it’s being hit, and what happens.

\Log::info('Resetting password for: ' . $request->email);

and

\Log::info('Password reset success for: ' . $request->email);

Check storage/logs/laravel.log.


Summary Checklist

  1. Double-check .env (DB, MAIL, APP_URL, SESSION)
  2. Fix permissions on storage/bootstrap/cache
  3. Clear config, cache, etc.
  4. Compare server timezone
  5. Inspect email queue and worker
  6. Check database user privileges
  7. Review web server logs
  8. Log inside controllers to see what’s happening

If you still have issues, let me know the content of your .env (hide sensitive info), logs, and any errors you do see.

Remember, debugging in production is often permissions, environment, or cache related!


If you need to debug more interactively, you can also install barryvdh/laravel-debugbar (disable in production after).


Let me know how it goes!

vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

Oh damn ... I forgot to define the SESSION_DOMAIN !

Please or to participate in this conversation.