Uncaught Exception: Error: Connection terminated unexpectedly
I have a Next.js app deployed on Vercel, using @neondatabase/serverless as a PostgreSQL client and @prisma/adapter-neon to integrate with Prisma. Occasionally, I get a Connection terminated unexpectedly error, which causes an unhandled exception and crashes the Node.js process with exit code 129 (SIGHUP). Here’s my setup:
Despite using the @neondatabase/serverless pool, which should be suited for serverless environments, I still see intermittent disconnections reported by Vercel logs. Does anyone know what might cause this in a serverless environment, and how to prevent these unexpected terminations?
6 Replies
plain-purpleOP•7mo ago
Bump
wise-white•7mo ago
I looked at similar errors in our Support system. What I'm seeing is:
- Make sure you're running the latest Prisma Client and Neon Sererless driver
- Look at connection pool timeout settings: https://neon.tech/docs/guides/prisma#connection-pool-timeouts
@Mahmoud or @Rishi Raj Jain anything you might suggest here?
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...
plain-purpleOP•7mo ago
@Daniel
Thank you!
Updated Prisma Client and Neon Serverless driver to their latest versions.
Checked the connection pool timeout settings as outlined in the Neon documentation.
However, the error still persists. Additionally, as shown in the attached image, it appears that timeout settings cannot be changed in the Vercel environment.
Could you please advise on any further steps or workarounds to resolve this issue?

wise-white•7mo ago
I see that you've been able to open a Support ticket. That's great. Hopefully, they can get you sorted out.
other-emerald•7mo ago
@tomolld
Check out the example at https://github.com/neondatabase/examples/blob/main/with-nextjs-prisma-edge/lib/prisma.server.ts (and match the code of instantiating the Prisma instance) which should work with Prisma, Next.js, Neon and Vercel and get rid of the sporadic errors.
plain-purpleOP•7mo ago
@Rishi Raj Jain
This is works! Thank you!