SQLiteSQLite SQLITE_BUSY

SQLite: Database Is Locked

SQLite SQLITE_BUSY means another process or connection has locked the database file and the current operation cannot proceed. SQLite uses file-level locking and allows only one writer at a time.

Example Query

-- Two processes opening the same .db file and writing simultaneously

Common Causes

  1. 1Two application instances writing to the same SQLite file concurrently
  2. 2A long-running transaction holding the write lock
  3. 3Unclosed connection from a crashed process still locking the file

How to Fix It

Use WAL mode for better concurrency: PRAGMA journal_mode=WAL. Set a busy timeout: PRAGMA busy_timeout=5000. Ensure all connections are properly closed. For high-concurrency workloads, consider migrating to PostgreSQL or MySQL.

Need a reliable database?

Try Supabase — free PostgreSQL with a generous free tier. No credit card required.

Get started free →

Got a query causing this error?

Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.

Analyze My Query →