readonly database SQL Origin: Data OSI layer 7 · Application Last updated 14 Oct 2026

sqlite3.OperationalError: attempt to write a readonly database

The process can’t write to the SQLite file or its directory.

Exact message you may see attempt to write a readonly database
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

  1. chown the file and its directory to the app user
  2. Store the DB on a writable volume
  3. Check open flags/URI

Detailed fix by platform

Linux

  1. sudo chown www-data:www-data /var/www/app/db /var/www/app/db/app.sqlite3

How to diagnose

  1. Permissions — File and directory writable by the app user?
  2. 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:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

002003 — Snowflake SQL compilation error: Object 'X' does not exist or not authorized (SQL)002003229 — SQL Server Msg 229: The SELECT permission was denied on the object (SQL)2295123 — SQL Server Msg 5123: CREATE FILE encountered operating system error 5 (Access is denied) while attempting to open the physical file (SQL)5123916 — SQL Server Msg 916: The server principal is not able to access the database under the current security context (SQL)916AADSTS65001 — AADSTS65001: The user or administrator has not consented to use the application (Azure)AADSTS65001Access to the path is denied — System.UnauthorizedAccessException: Access to the path 'x' is denied (.NET)Access to the path is…AccessControlListNotSupported — AccessControlListNotSupported: The bucket does not allow ACLs (AWS)AccessControlListNotS…database or disk is full — SQLite: database or disk is full (SQLITE_FULL) (SQL)database or disk is f…readonly …

Explore the map of this error Full error map →

🧠 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.