SQLite "Database Is Locked" (SQLITE_BUSY): What Actually Fixes It

Symptom

SQLITE_BUSY / database is locked errors under concurrent access.

Root cause

SQLite allows one writer; a second writer hits the lock and gives up.

Fix, in order

1. Enable WAL — the single best changePRAGMA journal_mode=WAL;
2. Give busy a timeout instead of failing instantlyPRAGMA busy_timeout=5000;
3. Serialize writes through one process/connection pool# one writer queue beats clever retries

Prevent it coming back

WAL + busy_timeout + short transactions covers most apps; Postgres beyond that.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

DevOps tools shelf

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.

Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog