1213 MySQL Origin: Data Last updated 13 Oct 2026

MySQL ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

MySQL detected a deadlock between two transactions and rolled one back.

Exact message you may see 1213 Deadlock found
Seen on: MySQL

Meaning

The SQL-level page explains deadlocks generally; for MySQL, SHOW ENGINE INNODB STATUS shows the latest deadlock with both statements.

Common causes

  • Rows locked in different orders
  • Missing indexes causing gap locks
  • Long transactions

⚡ Quick fix

  1. Retry the transaction
  2. Access rows in a consistent order
  3. Add indexes

Detailed fix by platform

MySQL

  1. SHOW ENGINE INNODB STATUS\G

How to diagnose

  1. Statements — Which two?
  2. Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

🔧 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: Data. Errors that are often confused with or caused by this one (click to open):

25P02 — ERROR: current transaction is aborted, commands ignored until end of transaction block (PostgreSQL)25P0240001 — ERROR: could not serialize access due to concurrent update (PostgreSQL)40001Deadlock — Deadlock found when trying to get lock; try restarting transaction (SQL)DeadlockError acquiring the state lock — Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked (Terraform)Error acquiring the s…idle-in-transaction timeout — FATAL: terminating connection due to idle-in-transaction timeout (PostgreSQL)idle-in-transaction t…Lock wait timeout — Lock wait timeout exceeded; try restarting transaction (MySQL 1205) (SQL)Lock wait timeoutORA-00054 — ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired (SQL)ORA-00054SQLITE_BUSY — sqlite3.OperationalError: database is locked (SQLITE_BUSY) (SQL)SQLITE_BUSY1213

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.