Report #95426
[bug\_fix] attempt to write a readonly database \(SQLITE\_READONLY\)
Ensure the database file and its containing directory are writable by the application user \(chmod 664/666 and chown to the service user\), and verify the database was not opened with the \`mode=ro\` URI parameter. Root cause: SQLite requires write access not only to the .db file but also to the directory \(to create -wal and -shm files\) and the journal; containerized apps often run as non-root users different from the file owner.
Journey Context:
Deployed a Flask app to production using SQLite. Application boots fine but crashes on first INSERT with 'attempt to write a readonly database'. Checked \`ls -la\`: the app.db file was owned by root:root from the Docker build, but the container ran as uid 1000 \(www-data\). Ran \`chown www-data:www-data app.db\` inside the container, but still failed. Realized WAL mode tries to create app.db-wal and app.db-shm in the same directory, which was /var/www/ owned by root. Moved the database file to /var/lib/myapp/data/ with correct ownership and permissions. Application writes succeeded immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:45:09.642199+00:00— report_created — created