Fixing “SQLSTATE[HY000]: General error: no such table: sessions” in Laravel (SQLite / MySQL)



This content originally appeared on DEV Community and was authored by Chirag Patel

If you’re running a fresh Laravel project and see this error:

Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1 no such table: sessions

don’t panic. This happens a lot when Laravel is using the database session driver but the required sessions table doesn’t exist yet.

In this post, we’ll go through why this happens and the two simple fixes (works for both SQLite and MySQL).

Why Does This Happen?

Laravel stores session data using different drivers. Common options include:

  • file → stores sessions in storage/framework/sessions (default).
  • database → stores sessions in a sessions database table.

If your .env has:

SESSION_DRIVER=database

Laravel expects a sessions table in your database. If the table doesn’t exist → you’ll see the error.

Solution 1: Quick Fix (Use File Sessions)

For local development, you don’t usually need database sessions.

  • Open your .env file.
  • Update this line:
SESSION_DRIVER=file
  • Restart your Laravel app:
php artisan serve

That’s it — your sessions will now be stored in files, and the error will be gone.

Solution 2: Proper Fix (Use Database Sessions)

If you want sessions stored in your database (recommended for production):

Step 1: Create the migration

php artisan session:table

Step 2: Run migrations

php artisan migrate

Now Laravel will create the sessions table in your database.

SQLite Users

If you’re on the default SQLite setup:

  • Make sure .env points to your database file:
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite
  • If the file doesn’t exist, create it:
touch database/database.sqlite

Then re-run migrations.

MySQL Users

If you switched to MySQL in .env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_db
DB_USERNAME=your_user
DB_PASSWORD=your_password
  • Create the database if it doesn’t exist:
mysql -u your_user -p -e "CREATE DATABASE your_db;"
  • Run:
php artisan migrate

This will create the sessions table inside your MySQL database.

Wrap Up

The error “no such table: sessions” in Laravel comes from using the database session driver without running the migrations.

  • Quick dev fix → use SESSION_DRIVER=file
  • Production fix → run php artisan session:table && php artisan migrate

Once that’s done, your app should work smoothly 🚀

👉 Pro tip: If you’re just getting started, stick with file sessions for local dev. Switch to database sessions later when deploying to staging/production.

💡 What’s your go-to session driver in Laravel projects — file, database, or maybe redis? Drop your preference in the comments 👇


This content originally appeared on DEV Community and was authored by Chirag Patel