Urgent: PostgreSQL Connectivity Issue - "Connection reset by peer"

sachinrohit-vtech
PRO

2 months ago

Hi Railway Support,

We are currently experiencing a critical issue with our PostgreSQL instance on Railway. Our application is consistently failing to connect to the database, and we are receiving the following repeated log error:

could not receive data from client: Connection reset by peer , too many clients already

This error is occurring continuously and is affecting multiple client connections.

We have verified that the issue is not originating from our application layer, and it appears to be a network-level disconnection or a problem with the PostgreSQL service itself.

Please investigate this as a priority and let us know if there is any maintenance or downtime on your end, or if any configuration changes are needed from our side.

Looking forward to your urgent support on this matter.

Best regards,

Megha

Solved

8 Replies

2 months ago

How many connections do you presume to be making to the database? When did this issue start to appear for your codebase?


Status changed to Awaiting User Response Railway 2 months ago


sachinrohit-vtech
PRO

2 months ago

We currently have three servers connected to this PostgreSQL database, each running instances of our application that maintain active connections for handling traffic.

The issue started occurring yesterday (May 27th), and we began observing a high volume of connection errors around 17:50 UTC, specifically the repeated error:

could not receive data from client: Connection reset by peer

There were no significant codebase or infrastructure changes from our end during that time, so we suspect it may be related to the database service or network layer.

Please let us know if you need connection pool configurations or any other specific details from our end to assist with the investigation.

Best regards,

Megha


Status changed to Awaiting Railway Response Railway 2 months ago


2 months ago

Yea, it's likely that you need to deploy PGBouncer in front of the database. It's likely that you had a number of spare connections that weren't cleaned up leading to the errors that you witnessed.

No data on our side is pointing to any issues with the platform it's self.

- Angelo


Status changed to Awaiting User Response Railway 2 months ago


sachinrohit-vtech
PRO

2 months ago

Hi Angelo,

We did attempt to set up PgBouncer previously, but our application was unable to establish a connection through it, which is why we reverted to connecting directly to PostgreSQL.

We've since retried the setup and successfully got PgBouncer running, but we were encountering the following error in the PgBouncer logs when attempting to connect to our actual database (adjustercopilot-develop):

login failed: db=adjustercopilot-develop user=pgbouncer_user_two

pooler error: no such database: adjustercopilot-develop

The database adjustercopilot-develop exists and is fully accessible when connecting directly to PostgreSQL, so it appears PgBouncer does not recognize it — possibly due to a single-database restriction in the managed configuration.

Could you please assist us with a proper setup guide or configuration that’s compatible with Railway’s environment? Specifically, we would appreciate help with:

  • Recommended PgBouncer configuration for use with Railway-hosted PostgreSQL

  • Any connection string format changes required from the application side

  • Whether multiple databases can be routed through Railway-managed PgBouncer, or if we must align with a specific default database name

We want to ensure our setup follows best practices and avoids connection exhaustion issues going forward.

Looking forward to your guidance

Best regards,

Megha


Status changed to Awaiting Railway Response Railway 2 months ago


2 months ago

This seems like it’s not an issue with the PGBouncer it’s self, but the name of the DB- you just need to connect to the dbname that you have.


Status changed to Awaiting User Response Railway 2 months ago


sachinrohit-vtech
PRO

2 months ago

Hello Angelo,

To clarify, the database we're trying to connect to is named adjustercopilot-develop, and it's definitely present in our PostgreSQL instance — we can connect to it directly without issues.

However, when connecting through PgBouncer, we receive the following log message:

login failed: db=adjustercopilot-develop user=pgbouncer_user_two pooler error: no such database: adjustercopilot-develop

This suggests PgBouncer is not recognizing or routing connections to that database name, even though it exists. From what I understand, PgBouncer must be explicitly configured to recognize multiple databases unless it’s in a mode like auth_query.

Could you confirm:

  • Does Railway’s managed PgBouncer currently support connecting to custom-named databases, or is it hardcoded to a specific DB (e.g., railway)?

  • Is there any way we can register or allow routing to adjustercopilot-develop via PgBouncer?

If PgBouncer can only proxy one DB name, we’re happy to adapt our setup — just want to be sure we’re aligning with the supported usage pattern.

Thanks again for your support!

Best regards,

Megha


Status changed to Awaiting Railway Response Railway 2 months ago


2 months ago

Which PgBouncer instance are you referring to? Railway doesn't offer a managed PgBouncer. The configuration has to be provided to you.

With that said, I want to get you in a good spot, but the boundary of responsibility for databases rests with the user, not Railway. Railway's database offering isn't managed. We can get you to a good spot to start, but database administration rests with you and your company.

Sorry I don't have any good news, but I do think the error that you posted is solvable by changing the user assuming it's the correct one.

- Angelo


Status changed to Awaiting User Response Railway 2 months ago


sachinrohit-vtech
PRO

2 months ago

Hello Angelo,

Thanks for the clarification — that makes sense now.

We had initially assumed the PgBouncer service was managed or pre-wired to a specific DB name (e.g., railway) based on default behavior, but it's clear now that the configuration is entirely in our hands.

Given that, here's what we've set up:

  • We deployed PgBouncer ourselves via Railway as a separate service.

  • Our PostgreSQL instance has a database named adjustercopilot-develop, and it's accessible directly.

  • We've configured PgBouncer but are seeing this error when connecting through it:

pooler error: no such database: adjustercopilot-develop

This implies that we likely need to explicitly define the database in the PgBouncer config — probably in the [databases] section of pgbouncer.ini.

We’ll move forward with hosting and managing PgBouncer config ourselves, and set up a [databases] entry like:

[databases] adjustercopilot-develop = host=your-postgres-host port=5432 dbname=adjustercopilot-develop

Appreciate your help in clarifying the boundaries and guiding us to the right spot.

Best regards,
Megha


Status changed to Awaiting Railway Response Railway 2 months ago


Status changed to Solved parmstar 2 months ago