Can't reach database server
Getting this a few times a day
PrismaClientKnownRequestError: Invalid
prisma.user.findUnique()
invocation:
Can't reach database server at ep-tight-voice-SERVERID-pooler.us-east-1.aws.neon.tech:5432
Please make sure your database server is running at ep-tight-voice-SERVERID-pooler.us-east-1.aws.neon.tech:5432
.
I have auto-scaling enabled, so what am I missing here? Codebase is Next.js + Prisma. I suspect there are places with Promise.all
that are cloggling the connection pool, but other than that what can I do to troubleshoot this better? TIA23 Replies
fascinating-indigo•5mo ago
yes i am also getting this
how can we solve this
adverse-sapphire•5mo ago
I suggest looking at the connection / connection pool timeout docs here: https://neon.tech/docs/guides/prisma#connection-timeouts
Neon
Connect from Prisma to Neon - Neon Docs
Prisma is an open source, next generation ORM that lets you to manage and interact with your database. This guide covers the following topics Connect to Neon from Prisma Use connection pooling with Pr...
stuck-chocolate•5mo ago
same thing happening to me
rare-sapphire•5mo ago
yeah oddly enough this has been happening for us more in the last 2-3 weeks whereas it wasn't a problem before.
adverse-sapphire•5mo ago
hm. That timing aligns with the Prisma ORM 6.6.0 release. https://www.prisma.io/blog/prisma-orm-6-6-0-esm-support-d1-migrations-and-prisma-mcp-server
This info from the Prisma team is related to another Neon-Prisma issue, but perhaps it applies — and maybe worth a try.
"We did some changes to driver adapters in the 6.6.0 release though.
Some users do not properly install prisma as a dev dependency but use e.g. npx prisma generate . This can lead to the generated code using the latest 6.6.0 interfaces, but the installed client is still older (e.g. 6.5.0). Most often this causes no obvious issues as we rarely changed the interfaces. But with 6.6.0 we did. 😬
So maybe let the user try to properly update prisma client and cli to 6.6.0. "
foreign-sapphireOP•5mo ago
We are using prisma 6.2.1 here, both client and cli.
Currently getting this:
Invalid
prisma.user.findUnique()
invocation:
Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 15, connection limit: 20)
DATABASE_URL=postgres://USER:PASS@SERVER-pooler.us-east-1.aws.neon.tech:5432/DBNAME?sslmode=require&connect_timeout=15&connection_limit=20&pool_timeout=15
DIRECT_URL=postgres://USER:PASS@SERVER.us-east-1.aws.neon.tech:5432/DBNAME?sslmode=require
Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
foreign-sapphireOP•5mo ago
Updated to 6.6.0, still happening
quickest-silver•5mo ago
@leofc
Can you share if the problem persists if you use https://github.com/neondatabase/examples/tree/main/with-nextjs-prisma-edge with your Neon database?
foreign-sapphireOP•5mo ago
@Rishi Raj Jain you mean using this prisma client? https://github.com/neondatabase/examples/blob/main/with-nextjs-prisma-edge/lib/prisma.server.ts
quickest-silver•5mo ago
Exactly!
foreign-sapphireOP•5mo ago
Awesome, we moved our plan, not sure if this relates, but monitoring it. Thanks
foreign-sapphire•4mo ago
@leofc I am facing same issue, did you fixed it ?
adverse-sapphire•4mo ago
Hi @leofc what issue are you seeing?
foreign-sapphireOP•4mo ago
@Daniel
Ex: Invalid
prisma.salesOrderItem.update()
invocation:
Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 15, connection limit: 20)Connection pool | Prisma Documentation
Prisma ORM's query engine creates a connection pool to store and manage database connections.
foreign-sapphireOP•4mo ago
@Levan Parastashvili it didn't happen for a while, I only upgrade my plan (was a legacy Vercel client) but it happened yesterday again
adverse-sapphire•4mo ago
It looks like you have increased your pool timeout and connection limit. Have you looked at the size of the machine where your application runs? As I understand it, that determines the number of connections available in the Prisma connection pool. https://neon.tech/docs/guides/prisma#connection-pool-timeouts
Failing that, I'd open a ticket with Neon support to investigate further: https://console.neon.tech/app/projects?modal=support
foreign-sapphireOP•4mo ago
@Daniel application is running in Vercel (Pro Plan) and not sure if I can find the number of physical CPUs. I assume you have hundreds of Vercel customers, so which number do you see here
adverse-sapphire•4mo ago
Unfortunately, we don't have a window into Vercel compute sizes where your app runs — we can only see the Neon database computes.
foreign-sapphireOP•4mo ago
@Daniel messaged the support but no answer. Last time I messaged that (for a sales call) it took one week to get a response
Not impressed with Neon at this point
adverse-sapphire•4mo ago
Hi @leofc My apologies. Can you provide me with your support ticket number (four digit number) ? I'll ping the team directly.
foreign-sapphireOP•4mo ago
#6538 - thank you
adverse-sapphire•4mo ago
Hi @leofc I see the new issue in our support system. For paid plans, support is within 3 business days.
https://neon.tech/docs/introduction/support
In the meantime, it looks like you're on Vercel Pro, so I'd reach out there to see if you can determine the machine/vm size where your app runs, as that impacts your Prisma connection pool size.
I'd also reach out the Prisma team to see if they have anything to offer.
@Rishi Raj Jain is there anything else here you can recommend?
foreign-sapphireOP•4mo ago
Thanks @Daniel - I posted in their support forum a few days ago: https://community.vercel.com/t/vercel-prisma-neon-and-connection-issues/10813
Vercel Community
Vercel, Prisma, Neon and connection issues
Running my application in Vercel (Pro Plan) and seeing these errors sometimes: Invalid
prisma.customer.findMany()
invocation: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 15, connection limit: 20) and Invalid prisma.salesOrder.findFirst()
invo...