SQLITE_PERM
SQLiteERRORNotablePermissionsofficial confidence

Access permission denied

Production Risk

High — all writes will fail until permissions are corrected.

What this means

SQLITE_PERM (3) is returned when the OS denies access to a file that SQLite needs to open or create. The file exists but the process lacks read or write permission.

Why it happens
  1. 1Database file owned by a different user with no group/world permissions.
  2. 2Read-only filesystem (e.g., Docker volume mounted read-only).
  3. 3SELinux or AppArmor policy blocking file access.
  4. 4WAL journal file or shm file not writable.
How to reproduce

Occurs on sqlite3_open() or the first write operation if permissions changed after open.

trigger — this will error
trigger — this will error
import os, sqlite3
os.chmod('my.db', 0o000)
try:
    sqlite3.connect('my.db')
except sqlite3.OperationalError as e:
    print(e)  # unable to open database file

expected output

sqlite3.OperationalError: unable to open database file

Fix 1

Fix 2

Fix 3

Fix 4

What not to do

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All SQLite errors