Demo, all content is generated
Question

SQLite works locally, breaks on Vercel with 'unable to open database file'

Solved · 105 views · asked by kai_makes · edited

My app uses a data.db file next to the code. Locally fine. On Vercel every request fails.

SqliteError: unable to open database file
What I’ve tried

Set the path to ./data.db, /tmp/data.db, and an absolute path. Committed the file to git.

Comment
Does the data need to change at runtime, or is it read-only reference data? If read-only you can just bundle it. fatima_z · edited
It needs writes, users save stuff. kai_makes · edited

1 answer

Marked as helpful by the asker
ines_data · edited

Vercel functions are read-only and stateless: the filesystem resets on every deploy and every cold start. A file database cannot live there.

Options by effort:

  • Turso (hosted SQLite, has a free tier, same SQL): change the connection string, done.
  • Supabase/Neon Postgres: more setup, more room to grow.

/tmp "works" until the function recycles, then your data is gone. Do not ship that.

Comment
Moved to Turso, only the connection code changed. Thanks. kai_makes · edited