P
Prisma2mo ago
RDG

Please, help me with this errors, I've got several customers complaining.

✖ Introspecting based on datasource defined in prisma\schema.prisma Error: P1017 Server has closed the connection. I can't connect to the database, yesterday everything was working good.
28 Replies
Prisma AI Help
Prisma AI Help2mo ago
You chose to compile with the bot. One moment while I piece together your answer… The error P1017: Server has closed the connection means that Prisma tried to connect to your database, but the database server closed the connection unexpectedly. This is a generic error and can be caused by several factors, including: - Database server issues (e.g., maintenance, restarts, network problems) - Exceeding connection limits or idle timeouts - Changes in Prisma or database configuration - Upgrades or changes in Prisma version (some users report issues after upgrading past certain versions) - Database provider-specific issues (e.g., Supabase, PlanetScale, SQL Server 2016, etc.) What you can do: 1. Check your database server logs for any errors or reasons why connections are being closed. Prisma is only reporting that the server closed the connection; the root cause is often in the database logs itself Some runs of CRONs end in error P1017. 2. Test with another database client (e.g., psql, DBeaver) to confirm if the database is reachable and stable. 3. Restart your database server if possible, as sometimes dangling or stale connections can cause this issue prisma migrate: P1017 Server has closed the connection. 4. Check for recent changes: If you recently upgraded Prisma, try downgrading to a previous version that worked (users have reported regressions after certain versions) prisma migrate dev fails with Error: P1017 (prisma > 5.9.1). 5. Network/Infrastructure: If your database is hosted in Kubernetes or behind a proxy, check for network interruptions or timeouts Prisma 6.3.1 npx prisma migrate dev causes P1017. 6. Database provider limitations: Some providers (e.g., Supabase, PlanetScale) may have temporary outages or connection limits. Sometimes, the issue resolves itself after a while PlanetScale — P1017: Serve r has closed the connection. If the problem persists, please gather logs from both Prisma (run with DEBUG=*) and your database, and check if any recent changes were made to your infrastructure or Prisma version. If you need further help, please provide more details about your setup and any recent changes.
Nurul
Nurul2mo ago
Hey @RDG Can you share the email id with which you created the Prisma account? I assume you are using Prisma Postgres
RDG
RDGOP2mo ago
yes bugadogc.yt@gmail.com this is the email connected to the prisma account everything was working fine yesterday and ive recently paid the prisma invoice, so I don't think its a payment issue
Nurul
Nurul2mo ago
In which environment are you getting this error? aztroagendas-dev or aztroagendas-prod?
RDG
RDGOP2mo ago
both
export const prisma = new PrismaClient({
datasourceUrl: env.DATABASE_URL,
log: dev ? ['query', 'error', 'warn'] : ['error']
});
export const prisma = new PrismaClient({
datasourceUrl: env.DATABASE_URL,
log: dev ? ['query', 'error', 'warn'] : ['error']
});
This is the way I'm handling the connection Schema:
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
Nurul
Nurul2mo ago
And you are using the Direct connection string (starting with postgres://) and not the accelerate one (starting with prisma+postgres://), right? Could you try restarting the database instance and see if it helps? You should be able to restart it from Settings tab in Prisma Console
RDG
RDGOP2mo ago
Yes, im using the direct connection And i already tried restarting it It didnt work
Nurul
Nurul2mo ago
Are you able to see the tables and your data in Studio on Prisma Console?
RDG
RDGOP2mo ago
yes
Nurul
Nurul2mo ago
I checked the logs and your database instance is responsive and returning data as expected 🤔 Could you try redeploying your application?
RDG
RDGOP2mo ago
yes, the issue here is the connection, i don't know what it is, I didn't do anything different
Nurul
Nurul2mo ago
Where is your app deployed?
RDG
RDGOP2mo ago
vercel but both vercel and local are closing the connection
Nurul
Nurul2mo ago
Oh, so your app running locally is also throwing the same error?
RDG
RDGOP2mo ago
yes and out of the blue, a couple hours before this wasn't happening
Nurul
Nurul2mo ago
That's very strange! What prisma version are you using?
RDG
RDGOP2mo ago
prisma : 6.16.1 @prisma/client : 6.16.1 the only thing I see that is different is 19 hours ago they released 6.17.0 and this last person in the chat is apparently having the same issue as me #ask-ai
Nurul
Nurul2mo ago
Could you do a force deployment on Vercel and try? I asked the person in #ask-ai if they are using Prisma Postgres as well. I am checking with team internally in the meantime.
RDG
RDGOP2mo ago
ok, thank you very much for helping me! i'll try redeploying now Same error
[500] GET /rnbarber
PrismaClientInitializationError:
Invalid `prisma.tenant.findUnique()` invocation:


Server has closed the connection.
at ei.handleRequestError (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:7568)
at ei.handleAndLogRequestError (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:6593)
at ei.request (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:6300)
at async a (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:130:9551)
at async getTenantBySlug (file:///var/task/vercel/path0/.svelte-kit/output/server/chunks/tenant.js:71:18)
at async Object.handle (file:///var/task/vercel/path0/.svelte-kit/output/server/chunks/hooks.server.js:118:26)
at async fn (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:3463:16)
at async internal_respond (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:3445:22)
[500] GET /rnbarber
PrismaClientInitializationError:
Invalid `prisma.tenant.findUnique()` invocation:


Server has closed the connection.
at ei.handleRequestError (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:7568)
at ei.handleAndLogRequestError (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:6593)
at ei.request (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:121:6300)
at async a (/var/task/vercel/path0/node_modules/@prisma/client/runtime/library.js:130:9551)
at async getTenantBySlug (file:///var/task/vercel/path0/.svelte-kit/output/server/chunks/tenant.js:71:18)
at async Object.handle (file:///var/task/vercel/path0/.svelte-kit/output/server/chunks/hooks.server.js:118:26)
at async fn (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:3463:16)
at async internal_respond (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:3445:22)
Nurul
Nurul2mo ago
Thanks for trying. I just shared it with team internally to get insights on what could be causing this
RDG
RDGOP2mo ago
ok, thank you. I'll wait.
Nurul
Nurul2mo ago
I think we know what's going on. Working on it
RDG
RDGOP2mo ago
just for extra information, the accelerate url is working fine. as far as connection goes
Nurul
Nurul2mo ago
@RDG Can you please check now?
RDG
RDGOP2mo ago
yes, just a sec working now apparently
Nurul
Nurul2mo ago
We had an issue only in US East region causing this. We are doing a postmortem and will share the findings 🙏 Apologies for the inconvience and thank you for reporting this
RDG
RDGOP2mo ago
Ok, thanks for you help. Just a question, is it already fixed? Can I redeploy using the postgres url instead of the accelerate one?
Nurul
Nurul2mo ago
Yes, this is resolved

Did you find this page helpful?