Prisma3mo ago

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?
Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
Connecting to your database | Supabase Docs
Explore the options for connecting to your Postgres database.
2 Replies
jonfanz3mo ago
Does your DB connection string have pooler in it? It could be that you're using the normal connection string with pgBouncer after it. https://www.prisma.io/docs/orm/overview/databases/supabase#specific-considerations
ww773mo ago
Yep, it has .pooler.supabase.com in it!