P
Prisma2mo ago
Arshia

Prisma postgress. Server has closed the connection error, please help.

{ "timestamp": "2025-10-08T14:08:49.655Z", "tests": [ { "name": "Environment check", "DATABASE_URL_set": true, "NODE_ENV": "production", "url_preview": "postgres://c2012740f591e59ba3f..." }, { "name": "Prisma client creation", "status": "SUCCESS" } ], "errors": [ { "test": "Connection test with timeout", "error": "\nInvalid prisma.$executeRaw() invocation:\n\n\nServer has closed the connection.", "type": "PrismaClientInitializationError" }, { "test": "Connection with pooling params", "error": "\nInvalid prisma.$executeRaw() invocation:\n\n\nServer has closed the connection.", "type": "PrismaClientInitializationError" }, { "test": "Database server info", "error": "\nInvalid prisma.$executeRaw() invocation:\n\n\nServer has closed the connection.", "type": "PrismaClientInitializationError" } ], "overall_status": "SOME_TESTS_FAILED" }
4 Replies
Prisma AI Help
Prisma AI Help2mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! The "Server has closed the connection" error with Prisma and PostgreSQL is a known issue and can be caused by several factors. Based on the knowledge sources, here are the most common causes and troubleshooting steps: 1. Connection Pooling Issues: If you're using connection pooling (e.g., with pgBouncer or cloud providers), ensure your pooling mode is compatible with Prisma. Prisma does not support pgBouncer in transaction pooling mode—only in session mode. Using transaction pooling can cause unexpected connection closures and errors like the one you see. If you are using a read/write split (master/replica) setup, this can also trigger the error if the replica closes connections unexpectedly or is not fully compatible with Prisma's connection handling. Try pointing both read and write URLs to the master to see if the error disappears Server has closed the connection with pgBouncer. 2. Database Server Availability: Double-check that your PostgreSQL server is running and accessible from your application environment. Try connecting with another client (like psql or pgAdmin) using the same credentials and host. Network issues, firewalls, or cloud provider restrictions can cause intermittent connection drops Can't reach database server. 3. Resource Limits: If your database is hitting connection or resource limits (CPU, memory), it may forcibly close connections. Check your database logs for any signs of resource exhaustion or forced disconnects. Increasing the connection_limit in your Prisma datasource or database may help, but be aware of your DB's max connections Connection pool timeouts. 4. Cloud Providers & Proxies: Some users have reported this error when connecting to managed databases (AWS RDS, GCP Cloud SQL, Supabase) or when using VPNs or proxies. Latency or network interruptions can ca use the server to close idle or long-running connections Remote DB issues. 5. Prisma Version: Ensure you are using the latest Prisma version, as several connection handling bugs have been fixed in recent releases. If none of these resolve your issue, please provide more details about your setup (pooling, cloud provider, Prisma version, etc.) for more targeted help.
Nurul
Nurul2mo ago
@Arshia Can you check now? We had an issue which caused connection errors
Arshia
ArshiaOP2mo ago
it worked now. thank you so much
Nurul
Nurul2mo ago
Thank you for confirming 🙏

Did you find this page helpful?