D1 no such table, next-on-pages binding

For Workes & Pages, what is the name of the domain?

Working on localhost for now

What is the error message?

D1_ERROR: no such table: users

What is the issue or error you’re encountering

D1 returns “D1_ERROR: no such table: users” in a next-on-pages app, despite having access to the binding and the referenced DB having said “users” table.

What steps have you taken to resolve the issue?

I tried specifying --d1 DB={db ID} to no avail. Before specifying this, I already had the binding in my wrangler.toml file, and when I started pages dev, the binding was already listed with the correct DB ID. I have verified the ID matches what is displayed on the Cloudflare Dashboard, and I have verified the table users exists when I click into the D1 page on the dashboard.

I’m running a next-on-pages app, which I think complicates the issue a bit. This error was encountered after I had run npx @cloudflare/next-on-pages@1 and when I was running npx wrangler pages dev .vercel/output/static. D1 is being accessed by a Next Auth D1 adapter (Auth.js | D1) if it makes a difference.

You can’t connect to a remote D1 database when developing locally with Pages.

You will need to seed the local database with data otherwise it’ll be empty.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.