# sqlite3.OperationalError: database is locked (SQLITE_BUSY)

**Code:** `SQLITE_BUSY` · **Category:** SQL · **Seen on:** SQL

Another connection holds a write lock on the SQLite file, and this one gave up waiting.

## 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

1. Keep write transactions short and commit promptly
2. Enable WAL mode and a busy timeout
3. Close GUI tools holding the database
4. Use PostgreSQL/MySQL for concurrent web workloads

## Detailed fix by platform

### SQL

1. 

```sql
PRAGMA journal_mode = WAL;
PRAGMA busy_timeout = 5000;
```


## How to diagnose

1. **Writers** — How many processes write?
2. **Holder** — Any open transaction or tool?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/sqlite-database-is-locked)
