Base table or view already exists Laravel Origin: Application & API Last updated 4 Nov 2026

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.

Exact message you may see 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
Seen on: Laravel PHP MySQL

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 migrate against the wrong database

⚡ Quick fix

  1. Dev: php artisan migrate:fresh
  2. Prod: add if (!Schema::hasTable('users')) guard or insert the row into migrations
  3. Check php artisan migrate:status

Detailed fix by platform

Laravel

  1. php artisan migrate:status ; dev only: php artisan migrate:fresh --seed

How to diagnose

  1. Table — Exists already?
  2. Status — migration recorded?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1022 — MySQL ERROR 1022 (23000): Can't write; duplicate key in table (MySQL)10221051 — MySQL ERROR 1051 (42S02): Unknown table 'x' (MySQL)10511060 — MySQL ERROR 1060 (42S21): Duplicate column name 'x' (MySQL)10601061 — MySQL ERROR 1061 (42000): Duplicate key name 'x' (MySQL)10611091 — MySQL ERROR 1091 (42000): Can't DROP 'x'; check that column/key exists (MySQL)10911146 — MySQL ERROR 1146 (42S02): Table 'db.table' doesn't exist (MySQL)1146Attempt to read property "x" on null — Laravel/PHP 8: ErrorException: Attempt to read property "name" on null (Laravel)Attempt to read prope…Command "x" is not defined — Laravel: Symfony\Component\Console\Exception\CommandNotFoundException: Command "make:livewire" is not defined. Did you mean one of these? (Laravel)Command "x" is not de…Base tabl…

Explore the map of this error Full error map →

🧠 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.