PrismaP
Prisma2y ago
3 replies
ww77

Error querying the database: FATAL: Max client connections reached

Hi! I'm building a NextJS app with Supabase as my DB, and using Trigger.dev for background jobs. I've been running into the "Max client connections reached" error a lot, and it's heavily impacting production.

I've gone through both of these docs:
- https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool
- https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pooler

My supabase DB URL looks like this: <DB_CONNECTION_STRING>?pgbouncer=true&connection_limit=200&connect_timeout=300&pool_timeout=0

I have thousands of long running jobs that should be closing the connection after each run, but the jobs sometimes run for minutes at a time.

How can I debug this further? Am I missing something obvious?
Prisma ORM's query engine creates a connection pool to store and manage database connections.
Connection pool | Prisma Documentation
Supabase
Explore the options for connecting to your Postgres database.
Connecting to your database | Supabase Docs
Was this page helpful?