P
Prisma•5d ago
Whimsy

Timed out fetching a new connection from the connection pool.

can someone actually give valid solution to An error occurred while trying to interact with the database, nothing i try works, im sure my service makes quite a lot of db requests, not sure how to see that inside of postgres or such, but how to fix this for once, it spams them like thousands
4 Replies
Prisma AI Help
Prisma AI Help•5d ago
You've gone full bot mode! Let me fetch that AI answer for you ASAP. The error "Timed out fetching a new connection from the connection pool" means all available connections in Prisma's pool are busy, and new queries can't get a connection before the timeout. This is common when your app sends many parallel queries or your database connection limit is too low for your workload. How to fix: 1. Increase connection_limit and/or pool_timeout: - In your DATABASE_URL, set a higher connection_limit (but not above your DB's max connections) and increase pool_timeout (default is 10s). Example:
postgresql://user:pass@host:port/db?connection_limit=40&pool_timeout=30

postgresql://user:pass@host:port/db?connection_limit=40&pool_timeout=30

- This gives Prisma more connections and more time to wait for a free one. But if your DB can't handle more connections, this won't help and may make things worse Optimizing the connection pool. 2. Reduce parallel queries: - If you use Promise.all or similar to run many queries at once, throttle or batch them. Too many concurrent queries will saturate the pool, regardless of its size Github Issue #5334. 3. Optimize queries and indexing: - Slow queries keep connections busy longer. Use indexes and fetch only needed data to speed up queries Possible causes for P6004. 4. Monitor DB and Prisma: - Use Postgres tools to check active connections (SELECT * FROM pg_stat_activity;) and query performance. Compare Prisma query times to raw SQL to spot bottlenecks Github Issue #12545. 5. Update Prisma: - Upgrade to the latest Prisma version, as many connection pool bugs have been fixed in recent releases Github Issue #13353. Summar y:
Increase connection_limit and pool_timeout if your DB allows, reduce parallel queries, optimize your queries, and keep Prisma up to date. If you still see issues, you may need to scale your database or use a connection pooler like PgBouncer. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Whimsy
WhimsyOP•5d ago
I manage the db, and below is db config, i also have set my project to use 80 connections in query string, but still i get spammed with that error, please ping me, its quite emergency
No description
Nurul
Nurul•3d ago
Did you specify any connection_limit or pool_timeout via the database connection string you provided to Prisma?
Whimsy
WhimsyOP•3d ago
tried without and with setting limit to 80, same thing

Did you find this page helpful?