Specified key was too long; max key length is 1000 bytes Laravel Origin: Application & API Last updated 4 Nov 2026

Laravel: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

An indexed string column exceeds the index size allowed by an older MySQL/MariaDB with utf8mb4.

Exact message you may see Specified key was too long; max key length is 767 bytesSQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too longmax key length is 1000 bytes LaravelSyntax error or access violation: 1071 Specified key was too long
Seen on: Laravel PHP MySQL

Meaning

Laravel defaults to utf8mb4 (4 bytes per char), so varchar(255) indexed = 1020 bytes, over the 767/1000-byte limit on old MySQL (< 5.7.7) or MariaDB (< 10.2.2). Upgrade the DB, enable innodb_large_prefix with DYNAMIC rows, or set Schema::defaultStringLength(191) in AppServiceProvider::boot().

Common causes

  • Old MySQL/MariaDB version
  • ROW_FORMAT not DYNAMIC
  • Unique index on a long varchar
  • utf8mb4 charset on legacy server
  • Shared hosting DB defaults

⚡ Quick fix

  1. Schema::defaultStringLength(191); in AppServiceProvider::boot
  2. Upgrade MySQL to 5.7.7+ / MariaDB 10.2.2+
  3. Or use 191-length columns for indexed fields

Detailed fix by platform

Laravel

  1. in app/Providers/AppServiceProvider.php: use Illuminate\Support\Facades\Schema; public function boot() { Schema::defaultStringLength(191); }

How to diagnose

  1. DB — Version?
  2. Column — Indexed varchar length?
  3. Charset — utf8mb4?

🔧 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)1146Base table or view already exists — Laravel: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (Laravel)Base table or view al…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…Specified…

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.