sqlite3.OperationalError: database is locked (SQLITE_BUSY)
Another connection holds a write lock on the SQLite file, and this one gave up waiting.
database is locked Meaning
SQLite allows one writer at a time. Long transactions, open cursors, a DB browser holding the file, or many concurrent web workers cause lock contention.
Common causes
- Concurrent writers (multiple workers/threads)
- A long-running transaction or uncommitted write
- DB Browser/IDE keeping the file open
- Network filesystems (NFS/SMB) with broken locking
⚡ Quick fix
- Keep write transactions short and commit promptly
- Enable WAL mode and a busy timeout
- Close GUI tools holding the database
- Use PostgreSQL/MySQL for concurrent web workloads
Detailed fix by platform
SQL
- sql
PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000;
How to diagnose
- Writers — How many processes write?
- Holder — Any open transaction or tool?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
- ORA-00933 ORA-00933: SQL command not properly ended
- Network-related error SQL Server: A network-related or instance-specific error occurred while establishing a connection to SQL Server. (provider: Named Pipes Provider, error: 40 / TCP Provider, error: 26)
- 1267 MySQL ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 13 Oct 2026