sqlite3.OperationalError: attempt to write a readonly database
The process can’t write to the SQLite file or its directory.
Seen on:
SQL
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026