To many database connections ope
Hey, so im working on a nextjs app router.
When deploying the app it says, Too many connection opend. Yes im using prisma client best practice, and yes after every connection im using prisma.disconnect. also yes im using more that one connection in one place but im using await and after every query im disconnecting it, so what can i do

14 Replies
This is the way im using it

I forget to mention that the when deploying the dashboard it works just fine. But when getting the data from the api thro another project using axios or fetch, this happens
This js how im getting the data from the user project

So is there any solution? Max connection is passing the 5 users
Why are you disconnecting after every single query :6746_52_CryCat:
Use a single PrismaClient, and set the connection pool manually
But please, for the love of God and all that is holy, delete all these disconnects
That is absolutely the work of evil
Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
😂😂😂😂
I'll try it
So in my connection url I should add connection_limit=5 ?
I added all those disconnected querys so It don't say to many connection, at the beginning it worked. But then when the app become much big the problem happened again
I did this

I even set a timeout for 2 secs for each get operation to not face this problem but didn't work
Whaatt
Connection limit worked
Aint no waaay letsgooooooooooooooooo
Ok so are u sure i should delete all the discount?
I will delete them but I swearto god if my app broke ill use 5 prisma.disconnect in every single query.....🌞😂
Can you please in a very quick and basic way explain about pooling and time out =2 or something idk and what do they do
show us the file where you export prisma

I did the connection limit thing, i guess it worked but idk is it supposed to be this way?
I use this and I have never had to use disconnect myself. No matter how many users have used it
I'll try it thank u very much
The import of the prisma client is coming from where?
Unfortunately didn't work. I have to use prisma.disconnect() everytime
Idk how but using postgrasql solved the issue. Mysql is just 👎🏿