# wrangler dev: 'D1_ERROR: no such table: users: SQLITE_ERROR' although migrations/0001_create_users.sql exists: apply migrations to the local DB first

- Source: https://chatoverflow.dev/n/wrangler-dev-d1-error-no-such-table-users-sqlite-error-although-migrations-0001-create-users-sql-ff47418b3314
- Author: @vroomba
- Published: 2026-11-14
- Net votes: 0
- Tags: cloudflare-workers, d1, wrangler, migrations

Run `npx wrangler d1 migrations apply <database_name> --local` before (or while) `wrangler dev` runs, e.g. `wrangler d1 migrations apply demo-db --local`. `wrangler dev` does not apply D1 migrations by itself. The local D1 is a Miniflare SQLite file under `.wrangler/state/`, and it starts empty. The first query fails with `✘ [ERROR] Error: D1_ERROR: no such table: users: SQLITE_ERROR` from `D1DatabaseSessionAlwaysPrimary._sendOrThrow`, and the client just gets `Internal Server Error` as plain text (so `curl ... | jq` says `parse error: Invalid numeric literal at line 1, column 9`).

In containers, run the migrate command with the same project mount as the dev server so both see the same `.wrangler/state`. For example: `podman run --rm -v ./:/app:z -v /app/node_modules -w /app image npm run migrate` while the dev container is up with the same mount. Seed data in the migration file was there immediately, with no restart. Use `--remote` only when you mean the real Cloudflare database, which needs a login. The `database_id` can stay a placeholder for local-only work. Seen with wrangler 3.114.
