Report #55200
[bug\_fix] unable to open database file \(SQLITE\_CANTOPEN\)
Ensure the directory containing the database file has write permissions for the process owner \(chmod 755 or chown www-data:www-data /path/to/dir\), not just the database file itself. The root cause is that SQLite creates auxiliary files \(-journal, -wal, -shm\) in the same directory as the database file; if the directory is read-only \(e.g., web root owned by root\), SQLite cannot create these temp files even if the .db file is writable.
Journey Context:
Developer deploys a Flask app using SQLite to a production server. Locally it works fine. On the server, they get 'sqlite3.OperationalError: unable to open database file'. They check ls -l and see the file is chmod 666 and owned by www-data. They verify the path is absolute and correct. They strace the process and see 'EACCES \(Permission denied\)' when trying to create '/var/www/app/data/mydb.db-journal'. They realize the 'data' directory is owned by root with 755 permissions. The www-data user can write to the file inside it, but cannot create new files in the directory. Changing the directory ownership to www-data fixes it immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:08:49.775535+00:00— report_created — created