Report #38833
[bug\_fix] attempt to write a readonly database \(SQLITE\_READONLY\)
Ensure the database file, its -wal file \(if in WAL mode\), and the -shm shared memory file are all owned by the user running the application process with write permissions \(chmod 660\). If the database is on an NFS mount, move it to a local filesystem, as SQLite's file locking is unreliable on NFS. If the -wal or -shm files were created by root during a manual test, delete them or chown them to the app user. The root cause is that WAL mode requires write access to the auxiliary -wal and -shm files, not just the main .db file.
Journey Context:
A developer deploys a Django app with SQLite in WAL mode to a VPS. The app runs as user 'web' but the developer previously ran manage.py migrate as root. The app starts but on first write throws 'attempt to write a readonly database'. The developer checks permissions on the .db file \(looks fine\), then notices the .db-wal and .db-shm files are owned by root with 644 permissions. The app cannot write to the -shm file, causing the readonly error. The developer deletes the stale -wal/-shm files and ensures the app user owns the database directory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:39:25.166553+00:00— report_created — created