Bolt database

Prisma Connection Pool Exhausted - Cannot Connect to Database

API requests start failing with 'too many connections' or 'connect ECONNREFUSED' errors. The database was working fine but suddenly stops accepting connections.

This typically happens under load or after the app has been running for a while, and restarting the app temporarily fixes it.

Error Messages You Might See

PrismaClientInitializationError: Can't reach database server at `localhost` Error: too many connections for role Error: connect ECONNREFUSED 127.0.0.1:5432
PrismaClientInitializationError: Can't reach database server at `localhost`Error: too many connections for roleError: connect ECONNREFUSED 127.0.0.1:5432

Common Causes

  1. Prisma Client not being reused across requests - creating new instances continuously
  2. Database connection pool size too small for concurrent requests
  3. Connections not being closed properly after queries
  4. Long-running queries holding connections idle
  5. Pool timeout set too low, causing connection exhaustion

How to Fix It

Create a singleton Prisma Client instance: export const prisma = new PrismaClient(); // import in routes

Configure connection pool in DATABASE_URL: postgresql://user:pass@host/db?schema=public&connection_limit=5

Add proper error handling and disconnect: process.on('SIGINT', async () => { await prisma.$disconnect(); })

Real developers can help you.

zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. David Olverson David Olverson Solo dev shipping production apps with AI-assisted development. I specialize in rescuing broken Lovable/Bolt/Cursor builds and taking them to production. 10+ apps shipped including SaaS CRMs, gaming platforms, real estate tools, and Discord bots. Stack: Next.js 16, TypeScript, Tailwind CSS, FastAPI, PostgreSQL, Prisma. I use Claude Code with 50+ custom skills for rapid delivery. Average turnaround: 2-4 weeks from broken prototype to production. Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What's the best way to use Prisma in serverless?

Create a singleton pattern with module-level instantiation to reuse connections across cold starts

What's a safe connection pool size?

For WebContainer: 2-3. For production: 10-20. Adjust based on concurrent users and query patterns

How do I debug connection issues?

Enable Prisma debug logging: DEBUG=prisma:* npm run dev

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help