Postgres connection issue
coderisehub
HOBBYOP

3 months ago

Hi,

I'm running a Spring Boot application together with Postgres, deploying in the same network. When I push something into my backend repository and the automatic deployment is started, there's a ~50% chance that it will fail with a postgres connection error.

Logs from backend:
2025-12-16T20:49:44.059Z ERROR 2 --- [mentor-backend] [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.

org.postgresql.util.PSQLException: The connection attempt failed.

Logs from Postgres:
2025-12-16 20:46:50.360 UTC [14136] LOG: could not receive data from client: Connection reset by peer

Redeployment helps, also with 50% probability.

Does anybody know what can be the reason?

Thanks in advance

Solved$10 Bounty

3 Replies

fra
HOBBYTop 10% Contributor

3 months ago

how are the db metrics? do you have any metrics to see how many connection your db is using?


fra

how are the db metrics? do you have any metrics to see how many connection your db is using?

coderisehub
HOBBYOP

3 months ago

Hi, thanks for the answer.

It's like a pet project with the only one daily user so far. So I'm not sure it's related to any kind of metrics. And it also happens only during the every ~second deployment of the backend, when Hikari tries to get a connection. Everything is fine when the server is already up.
I also don't have any such problems in AWS for instance, so it's definitely some sort of internal railway issue.


coderisehub
HOBBYOP

3 months ago

Hi and thanks for the detailed answer.
I added these configs to my app properties and today I've got zero failed deployments (all days before every 2nd deployment - unsuccsessful):

spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.initialization-fail-timeout=-1

Hopefuly it's not a coincidence and it completely resolved the issue.
Thanks again for the support!


Status changed to Solved noahd 3 months ago


Loading...