It looks like your DB hasn't been initialised properly. The error you've included is failing to count the items in the User list which (if you don't have sessions configured) is likely the first query to run – a count of items in each list is shown on the Admin UI the landing page so that's the first thing it does.

So something about how your migrations are being generated or applied in production isn't setup right. Most of the relevant docs on how this works are in the CLI guide, specifically, see the section about database migrations and the db.useMigrations flag.

Having db.useMigrations turned off can be handy if you're just playing around in dev. Keystone will automatically sync your DB structure to what's defined in your list configs whenever it starts, and does so without creating any physical migration files. If you're prototyping some change or just mucking around, this may be what you want but – if you're deploying somewhere – better to turn db.useMigrations on. Then, if Keystone detects changes to the DB when it runs, it'll prompt you to create a migration file, which can be tweaked to protect existing data if needed, tracked under version control (eg. git) and deployed.

Getting these migrations to run in an environment like Heroku is a little slightly weird as (assuming it's enabled for your app) Heroku can auto-scale. Migrations on the other hand need to be run exactly once. You also can't just lock the DB and run migrations when the first instance of the app starts – this delays the start up of the HTTP server so, if the migrations run for too long, Heroku may think the deployment has failed.

The way we suggest getting around this is to run migrations in the build staging. Fans of the 12-factor app methodology will notice this violated the separation of build and release stages but, for a simple Heroku deploy, it works fine. For larger/more serious apps, creating and applying migrations usually an area that needs significant thought and attention. The specific infrastructure and rollout processes required will be project dependant.

I'd also encourage you to check out the Keystone 6 Heroku example codebase if you haven't already. It's a little out of date but it shows the migrations and package.json scripts in action.

Answer from Molomby on Stack Overflow
🌐
GitHub
github.com › prisma › prisma › issues › 10633
The table `public.<TableName>` does not exist in the current database. · Issue #10633 · prisma/prisma
December 9, 2021 - 9 10 async function seed() { 11 // ✅ generate root organization → 12 const rootOrganization = await prisma.organization.create( The table public.Organization does not exist in the current database. at cb (/Users/.../Code/nest-boilerplate/packages/server/node_modules/@prisma/client/runtime/index.js:38683:17) at seed (/Users/.../Code/nest-boilerplate/packages/server/prisma/seed.ts:12:30) { code: 'P2021', clientVersion: '3.6.0', meta: { table: 'public.Organization' } } An error occurred while running the seed command: Error: Command failed with exit code 1: ts-node prisma/seed.ts ·
Author   prisma
Top answer
1 of 1
2

It looks like your DB hasn't been initialised properly. The error you've included is failing to count the items in the User list which (if you don't have sessions configured) is likely the first query to run – a count of items in each list is shown on the Admin UI the landing page so that's the first thing it does.

So something about how your migrations are being generated or applied in production isn't setup right. Most of the relevant docs on how this works are in the CLI guide, specifically, see the section about database migrations and the db.useMigrations flag.

Having db.useMigrations turned off can be handy if you're just playing around in dev. Keystone will automatically sync your DB structure to what's defined in your list configs whenever it starts, and does so without creating any physical migration files. If you're prototyping some change or just mucking around, this may be what you want but – if you're deploying somewhere – better to turn db.useMigrations on. Then, if Keystone detects changes to the DB when it runs, it'll prompt you to create a migration file, which can be tweaked to protect existing data if needed, tracked under version control (eg. git) and deployed.

Getting these migrations to run in an environment like Heroku is a little slightly weird as (assuming it's enabled for your app) Heroku can auto-scale. Migrations on the other hand need to be run exactly once. You also can't just lock the DB and run migrations when the first instance of the app starts – this delays the start up of the HTTP server so, if the migrations run for too long, Heroku may think the deployment has failed.

The way we suggest getting around this is to run migrations in the build staging. Fans of the 12-factor app methodology will notice this violated the separation of build and release stages but, for a simple Heroku deploy, it works fine. For larger/more serious apps, creating and applying migrations usually an area that needs significant thought and attention. The specific infrastructure and rollout processes required will be project dependant.

I'd also encourage you to check out the Keystone 6 Heroku example codebase if you haven't already. It's a little out of date but it shows the migrations and package.json scripts in action.

Discussions

PrismaClientKnownRequestError: The table `public.User` does not exist in the current database.
PrismaClientKnownRequestError: Invalid `prisma.user.count()` invocation: The table `public.User` does not exist in the current database. More on answeroverflow.com
🌐 answeroverflow.com
September 3, 2025
An error occurred handling a request for the Admin UI: Error: Prisma error: The table `main.User` does not exist in the current database.
Run database migrations. More on reddit.com
🌐 r/Heroku
3
1
November 8, 2022
PrismaClientKnownRequestError
It's not working even after migrate ... error that table can't be found: Failing on await this.prismaService.user.create The table public.Userpublic.User does not exist in the current database... More on answeroverflow.com
🌐 answeroverflow.com
May 1, 2025
[railway-deployment]: The table `public.User` does not exist in the current database.
I successfully created a Keystone v6 project and added a custom field. Despite encountering some errors, I managed to deploy the project on railway app. Nevertheless, I am currently facing a databa... More on github.com
🌐 github.com
0
May 7, 2024
🌐
GitHub
github.com › hoppscotch › hoppscotch › issues › 3203
[bug]: table `public.User` does not exist in the current database · Issue #3203 · hoppscotch/hoppscotch
July 20, 2023 - hoppscotch-backend | Error: hoppscotch-backend | Invalid `this.prisma.user.create()` invocation in hoppscotch-backend | /usr/src/app/dist/user/user.service.js:104:52 hoppscotch-backend | hoppscotch-backend | 101 async createUserSSO(accessTokenSSO, refreshTokenSSO, profile) { hoppscotch-backend | 102 const userDisplayName = !profile.displayName ? null : profile.displayName; hoppscotch-backend | 103 const userPhotoURL = !profile.photos ? null : profile.photos[0].value; hoppscotch-backend | → 104 const createdUser = await this.prisma.user.create( hoppscotch-backend | The table `public.User` does not exist in the current database.
Author   hoppscotch
🌐
Answer Overflow
answeroverflow.com › m › 1412773974118502572
PrismaClientKnownRequestError: The table `public.User` does not exist in the current database. - Wasp
September 3, 2025 - at Ln.handleRequestError ... clientVersion: '5.19.1', meta: { modelName: 'User', table: 'public.User' } } 🐝 This error can happen if you did't run the database migrations....
🌐
Reddit
reddit.com › r/heroku › an error occurred handling a request for the admin ui: error: prisma error: the table `main.user` does not exist in the current database.
r/Heroku on Reddit: An error occurred handling a request for the Admin UI: Error: Prisma error: The table `main.User` does not exist in the current database.
November 8, 2022 -

I tried to deploy a keystone app to Heroku and I did it but while I tried to open the app I got the following error:
An error occurred handling a request for the Admin UI: Error: Prisma error: The table `main.User` does not exist in the current database.
Here's a screenshot containing more details about the error:

🌐
Answer Overflow
answeroverflow.com › m › 1367292026478923947
PrismaClientKnownRequestError - Prisma
May 1, 2025 - It's not working even after migrate dev --name users and generate commands. model User { id Int @default(autoincrement()) @id email String @unique password String @@map("users") } Model is using @@Map, and running from Nest.JS throws error that table can't be found: Failing on await this.prismaService.user.create The table public.Userpublic.User does not exist in the current database
🌐
GitHub
github.com › keystonejs › keystone › issues › 9136
[railway-deployment]: The table `public.User` does not exist in the current database. · Issue #9136 · keystonejs/keystone
May 7, 2024 - [railway-deployment]: The table public.User does not exist in the current database.#9136 · Copy link · bilal1031 · opened · on May 7, 2024 · Issue body actions · I successfully created a Keystone v6 project and added a custom field. Despite encountering some errors, I managed to deploy the project on railway app.
Author   keystonejs
🌐
GitHub
github.com › calcom › docker › issues › 323
Table public.users does not exist · Issue #323 · calcom/docker
February 3, 2024 - @calcom/web:start: 11:54:54:357 ERROR[redactError] Error: {"name":"PrismaClientKnownRequestError","code":"P2021","clientVersion":"5.4.2","meta":{"table":"public.Feature"}} @calcom/web:start: PrismaClientKnownRequestError: @calcom/web:start: Invalid `prisma.user.count()` invocation: @calcom/web:start: @calcom/web:start: @calcom/web:start: The table `public.users` does not exist in the current database.
Author   calcom
Find elsewhere
🌐
GitHub
github.com › calcom › cal.com › issues › 126
Error: The table `public.users` does not exist in the current database. · Issue #126 · calcom/cal.com
Issue Summary Message: Error in Prisma Client request: Error: The table public.users does not exist in the current database. Steps to Reproduce update DATABASE_URL Open prisma studio load schema Se...
Author   calcom
🌐
GitHub
github.com › calcom › docker › issues › 89
The table `public.users` does not exist in the current database · Issue #89 · calcom/docker
February 22, 2022 - Message: Error in Prisma Client request: Invalid `prisma.user.findMany()` invocation: The table `public.users` does not exist in the current database.
Author   calcom
🌐
GitHub
github.com › prisma › react-native-prisma › issues › 18
The table `main.User` does not exist in current database · Issue #18 · prisma/react-native-prisma
June 6, 2024 - I have followed the tutorial and face below issue while creating user. The table `main.User` does not exist in the current database.] WARN Possible Unhandled Promise Rejection (id: 4): [PrismaClien...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 12938
The table `(not available)` does not exist in the current database. · Issue #12938 · prisma/prisma
April 23, 2022 - throw new PrismaClientKnownRequestError(message, e.code, this.client._clientVersion, e.meta); ^ PrismaClientKnownRequestError: Invalid `prisma.user.findMany()` invocation in C:\Users\AriesAsAkshay\OneDrive\Documents\GitHub\PrismaFrog\src\index.js:13:40 10 const { PrismaClient } = require('@prisma/client'); 11 const prisma = new PrismaClient(); 12 async function main() { → 13 const allUsers = await prisma.user.findMany( The table `(not available)` does not exist in the current database.
Author   prisma
🌐
Laracasts
laracasts.com › discuss › channels › laravel › sqlstate42p01-undefined-table-7-error-relation-usr-user-does-not-exist-line-1-select-from-usr-user-where-deleted-at-is-null-and-email
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "usr_user" does not exist LINE 1: select * from usr_user where deleted_at is NULL and email = ... ^
March 26, 2023 - If the query returns no results, then the table does not exist and you need to create it. You can create the table using a migration in Laravel. Here's an example migration that creates a "usr_user" table: use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; ...
🌐
Fly.io
community.fly.io › questions / help
Table Doesn't Exist in Database - Questions / Help - Fly.io
April 26, 2022 - I’m making an education website using remix.run and prisma, and uploaded everything without errors, but I’m getting this error:
🌐
RedwoodJS Community
community.redwoodjs.com › get help and help others
Problem with model and existing db - Get Help and Help Others - RedwoodJS Community
May 3, 2021 - Hi, I have a postgresql db that already have tables populated with tons of data. I could not use the “prisma pull” cli as prisma does not handle cross schema references (yet, #1175), so I crated the model to one of the…
🌐
GitHub
github.com › better-auth › better-auth › issues › 5430
Non-public schema CLI migration · Issue #5430 · better-auth/better-auth
October 20, 2025 - // better-auth.config.ts import { betterAuth } from 'better-auth'; import { Pool } from 'pg'; const pool = new Pool({ host: 'localhost', port: 5432, user: 'postgres', password: 'password', database: 'mydb', options: '-c search_path=auth', // Also tried with a connection string as in the doc, same issue }); export const auth = betterAuth({ database: pool, emailAndPassword: { enabled: true, }, }); export default auth; Have an existing table named user in the public schema: CREATE TABLE public.user ( id SERIAL PRIMARY KEY, email VARCHAR(255) NOT NULL, name VARCHAR(255) ); ... alter table "user" add column "emailVerified" boolean not null; alter table "user" add column "image" text; alter table "user" add column "createdAt" timestamptz default CURRENT_TIMESTAMP not null; alter table "user" add column "updatedAt" timestamptz default CURRENT_TIMESTAMP not null;
Author   better-auth
🌐
GitHub
github.com › prisma › prisma › issues › 22299
relationJoins: "The table `(not available)` does not exist in the current database." · Issue #22299 · prisma/prisma
December 7, 2023 - Bug description Updated Prisma from v5.4.2 to v5.7.0 to test out the "relationJoins" preview feature. Most queries work as expected but there was one that gave me this error when executin...
Author   prisma