// SQLite error reference

SQLITE_PROTOCOL: locking protocol

In WAL mode, a connection lost the race to start a transaction many times over several seconds and gave up. Very rare; a sign of heavy write contention.

Result code
SQLITE_PROTOCOL
Name
15
Category
Primary result codes
Error message
locking protocol

What it means

The SQLite documentation describes SQLITE_PROTOCOL (15) as a problem with the file locking protocol, currently only returned in WAL mode when starting a transaction. When two connections race to start a transaction, the loser backs off and retries; if the same connection keeps losing for several seconds, it returns SQLITE_PROTOCOL. It should appear only with many processes competing hard to write the same database.

Common causes

  • Many processes writing the same WAL-mode database at once.
  • File locking that misbehaves, for example on a network file system.

How to fix it

  1. Reduce the number of concurrent writers, for example by funnelling writes through one process or a queue.

  2. Keep the database on a local disk with working locks.

  3. Treat it like SQLITE_BUSY: retry the transaction after a short pause.

Related errors

More primary result codes errors

The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.

// fewer errors, faster fixes

Work on SQLite in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.