Postgres Database connection limit (Our clients are having a bad UX bc the DB is failing)
mirantes
PROOP

7 hours ago

I've bump up my connection limit for all my postgres databases to 500, but for some reason I always reach the limit of 500.

I've already ensured that my application to the database only make at max 100 connection.

Plus I've been monitoring the databases and Im very far from the threshold. My connection limit is always 1 active, and maybe 10 idle. and I still have more than 400 connection available.

Please help me fix this because my application is always failing.

And this happens to all my databases both in production and in development.

This is my project ID: "https://railway.com/project/70d5f2ef-0753-4870-8cf6-b8a6948688da/service/a241dacf-2315-47f0-b4ba-e8c892752465"

You can also check this service in specific which is our feed service.

$20 Bounty

2 Replies

Status changed to Awaiting Railway Response Railway about 7 hours ago


mirantes
PROOP

4 hours ago

For example this are my connection states, but I keep on getting always max connection reached

Screenshot 2026-05-25 at 14.12.44.png

Screenshot 2026-05-25 at 14.13.21.png


sam-a
EMPLOYEE

an hour ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open sam-a about 1 hour ago


The 500 limit can still be hit even if the dashboard says 1 active / 10 idle, especially if connections are opening/closing fast or coming from more replicas/processes than expected.

I’d run this directly on the DB first:

select application_name, usename, client_addr, state, count(*)
from pg_stat_activity
group by 1,2,3,4
order by count(*) desc;

If it shows a lot from the same service, cap pool size per process. With multiple replicas/workers, “max 100” becomes 100 * replicas * processes, so it can still hit 500 pretty easily.

Also check for jobs/serverless-style code creating a new client per request instead of reusing a pool. If you use Prisma, set connection_limit in the DB URL and consider PgBouncer for pooled connections.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...