22 days ago
I have all the time:
sometimes it works but most of the time it looks like in the screenshot
Why?
Attachments
1 Replies
22 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 22 days ago
4 days ago
A couple of questions to narrow this down: is your app connecting to the database over the public TCP proxy (*.proxy.rlwy.net:PORT) or the private domain (postgres.railway.internal:5432)?
If it's the public proxy: intermittent failures there usually mean the connection is traversing the public internet every time — switch to the private network if both services are in the same project/environment. It's more stable, lower latency, and free.
If you're already on private networking and connections drop intermittently, the usual causes are:
Connection pool exhaustion — Postgres has a max_connections cap; serverless-style code that opens a connection per request will exhaust it. Use a pool with a sane max.
Idle connections being reaped — set your pool's idle timeout below ~5 minutes or enable TCP keepalive.
App connecting before DNS/network is ready at boot — add retry-with-backoff on startup.
If you paste the actual error text (rather than the screenshot), it'll be much easier to give you a precise fix.