Launch offer: everything is 100% off. Download any skill free, no sign-up. Get the skills
TechFixError fixesBroke after deploy
Broke after deploy

SQLITE_CANTOPEN on Vercel or serverless hosting

The error (wording depends on the driver)
SQLITE_CANTOPEN: unable to open database file

# better-sqlite3:
SqliteError: unable to open database file
Short answer

SQLite is a file, and serverless functions don't have a disk that keeps files. Move to a hosted database, or run the app on a server with a persistent volume.

Why it happens

SQLite stores everything in one file next to your code. On your laptop that file sticks around. On serverless hosting the file system is read-only except /tmp, each instance gets its own temporary storage, and nothing is shared between instances. Vercel's own guide says SQLite can't be used with Vercel for this reason.

The symptoms vary: the file can't be opened (SQLITE_CANTOPEN), it can't be written (SQLITE_READONLY), or it works for a while and then the data "resets" after a deploy or a cold start.

Fix it by hand

  1. Confirm it's SQLite. Look for file:./dev.db in your database URL, provider = "sqlite" in a Prisma schema, or new Database('data.db') in code.
  2. Pick where the data will live. Either a hosted database (Postgres or MySQL from a managed provider, or a hosted libSQL service if you want to keep SQLite syntax), or a different kind of hosting: a server or container with a persistent volume, where a SQLite file is fine.
  3. Don't move the file to /tmp. It would open, but every instance would get its own copy and the data would vanish when the instance does.
  4. Move the schema and data. Point your ORM at the new database, create the tables (for Prisma, switch the provider and run your migrations against the new URL), then export from the SQLite file and import into the new database.
  5. Set the new database URL in your host's production variables and redeploy.

Stop it happening again

Let TechFix do this for you

Broke After Deploy $9

Broke After Deploy detects SQLite used as the database on serverless hosting, plus other code that writes files the server won't keep, before your first deploy.

  • Checks your project for 37 known causes of "works locally, breaks in production" and runs your production build.
  • Paste the error and it finds the cause in your code, then lists what will break next.
  • Verdict first. Every finding shows the file and line, what it breaks, and the fix as a diff that is applied only with your OK.

Broke After Deploy: how it works, with examples · Install guide

Works with Claude Code, Claude.ai, Cursor, Codex and other agents that read SKILL.md files. No installs, no accounts, works offline. No-questions refund.

Sources (checked 2026-10-13)