Frequent Database Connection Drops randomly on Pro Plan (Internal URL)
chaudharyali14
PROOP

20 days ago

Hi Railway Support,

We are experiencing recurring PostgreSQL connection drops on our Pro plan. This is causing downtime for our production POS (Point of Sale) system.

Setup:

- Plan: Pro (serverless disabled)

- Services: 2 NestJS containers (API + Worker) + PostgreSQL (Railway native) + Redis (Bitnami)

- Database URL: Using internal URL (postgres.railway.internal:5432)

- ORM: Prisma with connection pool (10 connections)

Issue:

- PostgreSQL connections drop at random intervals (sometimes 10 min, sometimes 20 min, sometimes 57 min)

- When connections drop, all pooled connections die simultaneously

- This causes our entire application to become unresponsive (all endpoints return 499/502)

- PostgreSQL logs show: could not receive data from client: Connection reset by peer

- Recovery requires manual redeployment

What we have already tried:

- Using internal URL instead of public proxy

- Removed pgbouncer=true from connection string (not using PgBouncer)

- Removed socket_timeout parameter

- Added 30-second keepalive pings (SELECT 1)

- Added auto-reconnect logic on connection failure

- Added statement_timeout=30000 to prevent hung queries

Questions:

1. Does Railway's internal networking have an idle TCP connection timeout? If so, what is the interval?

2. Is there a recommended keepAlive interval for PostgreSQL connections on Railway?

3. Are there any known issues with long-lived database connections on Railway's internal network?

4. Is there any infrastructure maintenance or connection cycling happening at regular intervals?

Logs showing the issue:

2026-02-16 19:15:17.368 UTC [2105] LOG: could not receive data from client: Connection reset by peer

2026-02-16 19:15:17.369 UTC [2103] LOG: could not receive data from client: Connection reset by peer

2026-02-16 19:15:17.369 UTC [2107] LOG: could not receive data from client: Connection reset by peer

(8 connections dropped simultaneously)

Any guidance on maintaining stable long-lived connections would be appreciated.

Thank you.

$30 Bounty

3 Replies

Railway
BOT

20 days 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 Railway 20 days ago


darseen
HOBBYTop 5% Contributor

20 days ago

If the issue is related to an idle TCP connection timeout, you can try appending ?connect_timeout=300&keepalives=1&keepalives_idle=30&keepalives_interval=10&keepalives_count=5 to your DATABASE_URL to resolve the issue. This sends empty ACK packets to the socket, keeping the connection alive.


chaudharyali14
PROOP

18 days ago

not resolved after changing the url, after 15 minute same issue come again , than again need to redeploy again[Nest] 13 - 02/18/2026, 4:50:43 PM LOG [ReportsService] [PERF] Done in 28ms

[Nest] 13 - 02/18/2026, 4:58:55 PM DEBUG [ReportsService] [PERF] Report Start: daily | calendar

[Nest] 13 - 02/18/2026, 4:58:55 PM DEBUG [ReportsService] [PERF] ChartData: 8ms

[Nest] 13 - 02/18/2026, 4:58:55 PM LOG [PrismaService] Disconnecting from PostgreSQL...


Status changed to Open brody 18 days ago


chaudharyali14
PROOP

18 days ago

postgresql://postgres:@postgres.railway.internal:5432/railway?connect_timeout=300&keepalives=1&keepalives_idle=30&keepalives_interval=10&keepalives_count=5 is this correct way


Loading...