sqlite3.OperationalError: attempt to write a readonly database
The process can’t write to the SQLite file or its directory.
attempt to write a readonly database Meaning
SQLite needs write access to the file and the folder (for journal/WAL files). Web servers running as www-data, read-only container layers and app bundles cause it.
Common causes
- File owned by another user
- Directory not writable (journal can’t be created)
- Read-only filesystem/container
- Opened with mode=ro
⚡ Quick fix
- chown the file and its directory to the app user
- Store the DB on a writable volume
- Check open flags/URI
Detailed fix by platform
Linux
sudo chown www-data:www-data /var/www/app/db /var/www/app/db/app.sqlite3
How to diagnose
- Permissions — File and directory writable by the app user?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🔧 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
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 14 Oct 2026