Laravel: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists
A migration tries to create a table that is already in the database.
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already existsBase table or view already existsTable already exists Laravel migrationSQLSTATE[42P07]: Duplicate table: 7 ERROR: relation already exists Meaning
Usually the table was created manually or a previous migration run failed midway (MySQL DDL isn't transactional), leaving a table with no migration record. Fix by dropping the table (dev only) and re-running, adding Schema::hasTable checks, or inserting the migration record. Use migrate:fresh only on dev data.
Common causes
- Table created manually or by a failed earlier migration
- Migrations table out of sync
- Duplicate migration files for the same table
- Restored DB dump without the migrations table data
- Running
migrateagainst the wrong database
⚡ Quick fix
- Dev:
php artisan migrate:fresh - Prod: add
if (!Schema::hasTable('users'))guard or insert the row intomigrations - Check
php artisan migrate:status
Detailed fix by platform
Laravel
php artisan migrate:status; dev only:php artisan migrate:fresh --seed
How to diagnose
- Table — Exists already?
- Status — migration recorded?
- DB — Right one?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Laravel
- MassAssignmentException Laravel: Illuminate\Database\Eloquent\MassAssignmentException: Add [x] to fillable property to allow mass assignment
- The GET method is not supported for route Laravel: The GET method is not supported for route x. Supported methods: POST (MethodNotAllowedHttpException)
- Route [login] not defined Laravel: Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026