Database Connection - All the time
kamilobrzut
HOBBYOP

22 days ago

I have all the time:

image.png

sometimes it works but most of the time it looks like in the screenshot

Why?

Attachments

$10 Bounty

1 Replies

Railway
BOT

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


stewiezgaming-web
HOBBYTop 10% Contributor

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.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...