P
Prisma6mo ago
doowb

Remix, prisma, neon, fly.io: Can't reach database server

Hi, I'm using prisma in a remix app deployed to fly.io and connecting to a neon db. Everything was deploying and working fine at first, then after a deployment on June 18th, the prisma client keeps showing "Can't reach database server at DATABASE_URL". After trying out some ideas with someone from neon, I traced through my server logs to find the last time it worked, and found that between a successful deployment and the broken one, prisma v6.10.0 was related. PNPM automatically installed that when building my docker image and I'm not finding anything else that might be related. I tried pinning prisma to v6.9.0, but I'm still getting the same error. I'm not sure how to reproduce this or if the problem is with the prisma client so I can't really open a bug report. Has anyone else see this issue? I'm not using any prisma adapters so I'm probably using a rust engine. I'm also able to run prisma cli commands and connect to the neon database with prisma studio without any issues.
1 Reply
Prisma AI Help
Prisma AI Help6mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! This "Can't reach database server" (P1001) error with Prisma, Remix, Neon, and Fly.io is a known, recurring issue that can have multiple causes. Based on the knowledge sources: 1. Neon Compute Idle State: Neon databases can go idle after 5 minutes of inactivity. When Prisma tries to connect, Neon may need a few seconds to activate, which can cause a timeout. You can increase the connect_timeout parameter in your DATABASE_URL to give Neon more time to wake up. For example:
DATABASE_URL=postgres://user:password@host/db?connect_timeout=15

DATABASE_URL=postgres://user:password@host/db?connect_timeout=15

You can also try increasing pool_timeout if needed. See Resolving connection timeouts for details. 2. Prisma Rust Query Engine: The default Prisma setup uses a Rust-based query engine, which has been reported to cause intermittent connectivity issues, especially on platforms like Fly.io and with Neon. Some users have found that switching to driver adapters (Node.js-based drivers) can help, as this bypasses the Rust engine. Prisma plans to make driver adapters the default in v7. You can try this approach to see if it resolves your issue Prisma client can't reach database server randomly. 3. IPv6 Issues: If your DATABASE_URL uses an IPv6 address, Prisma may not connect properly. Workarounds include switching to an IPv4 address or using a .internal hostname if available Prisma can't connect with an IPv6 host. 4. Concurrency and Connection Limits: High concurrency or too many simultaneous connections can also trigger this error. If you’re running many parallel queries, try reducing concurrency or increasing connection limits. If you’ve already pinned Prisma to an earlier version and the issue persists, it’s likely not a regression in Prisma itself but related to one of the above factors. If you can connect with Prisma Studio and CLI, the issue is likely with runtime connection handling, not basic connectivity. If none of these solutions work, consider switching to driver adapters and increasing your connection timeouts as a next step. ✅ Great, thanks for letting us know that this solved your question!

Did you find this page helpful?