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

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.

Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Alvin Voo Alvin Voo I’ve watched the tech landscape evolve over the last decade—from the structured days of Java Server Pages to the current "wild west" of Agentic-driven development. While AI can "vibe" a frontend into existence, I specialize in the architecture that keeps it from collapsing. My expertise lies in the critical backend infrastructure: the parts that must be fast, secure, and scalable. I thrive on high-pressure environments, such as when I had only three weeks to architect and launch an Ethereum redemption system with minimal prior crypto knowledge, turning it into a major revenue stream. What I bring to your project: Forensic Debugging: I don't just "patch" bugs; I use tools like Datadog and Explain Analyzers to map out bottlenecks and resolve root causes—like significantly reducing memory usage by optimizing complex DB joins. Full-Stack Context: Deep experience in Node.js and React, ensuring backends play perfectly with mobile and web teams. Sanity in the Age of AI: I bridge the gap between "best practices" and modern speed, ensuring your project isn't just built fast, but built to last. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help Franck Plazanet Franck Plazanet I am a Strategic Engineering Leader with over 8 years of experience building high-availability enterprise systems and scaling high-performing technical teams. My focus is on bridging the gap between complex technology and business growth. Core Expertise: 🚀 Leadership: Managing and coaching teams of 15+ engineers, fostering a culture of accountability and continuous improvement. 🏗️ Architecture: Enterprise Core Systems, Multi-system Integration (ERP/API/ETL), and Core Database Structure. ☁️ Cloud & Scale: AWS Expert; architected systems handling 10B+ monthly requests and managing 100k+ SKUs. 📈 Business Impact: Aligning tech strategy with P&L goals to drive $70k+ in monthly recurring revenue. I thrive on "out-of-the-box" thinking to solve complex technical bottlenecks and am always looking for ways to use automation to improve business productivity. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. Caio Rodrigues Caio Rodrigues I'm a full-stack developer focused on building practical and scalable web applications. My main experience is with **React, TypeScript, and modern frontend architectures**, where I prioritize clean code, component reusability, and maintainable project structures. I have strong experience working with **dynamic forms, state management (Redux / React Hook Form), and complex data-driven interfaces**. I enjoy solving real-world problems by turning ideas into reliable software that companies can actually use in their daily operations. Beyond coding, I care about **software quality and architecture**, following best practices for componentization, code organization, and performance optimization. I'm also comfortable working across the stack when needed, integrating APIs, handling business logic, and helping transform prototypes into production-ready systems. My goal is always to deliver solutions that are **simple, efficient, and genuinely useful for the people using them.**

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