Posgresql cant connect without sslmode=disable inside railway
pbird
HOBBYOP

3 months ago

I have a NestJS server running in a node-22:alpine container. Everything was working fine before, but suddenly my NestJS server started crashing with the error:

ELIFECYCLE  Command failed

The app restarts automatically, but it keeps crashing again after around 10 retries.

I tested the same container locally and connected to PostgreSQL on Railway without changing anything — it works fine locally. But when running on Railway, the app does not start unless I set sslmode=disable in the connection string.

Here are the PostgreSQL logs I see on Railway:

2025-09-01 19:46:16.594 UTC [509] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:16.594 UTC [508] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:16.594 UTC [510] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:16.594 UTC [505] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:54.701 UTC [539] LOG: could not accept SSL connection: EOF detected

2025-09-01 19:46:54.701 UTC [542] LOG: could not accept SSL connection: EOF detected

2025-09-01 19:46:54.701 UTC [541] LOG: could not accept SSL connection: EOF detected

2025-09-01 19:46:54.701 UTC [540] LOG: could not accept SSL connection: EOF detected

2025-09-01 19:46:54.701 UTC [543] LOG: could not accept SSL connection: EOF detected

2025-09-01 19:46:54.701 UTC [536] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:54.701 UTC [537] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:54.701 UTC [538] LOG: could not receive data from client: Connection reset by peer

2025-09-01 19:46:54.701 UTC [532] LOG: could not receive data from client: Connection reset by peer

Solved$10 Bounty

5 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


noahd
EMPLOYEE

3 months ago

Hey! Can you try switching to slim from alpine i have a theory that there might be something missing from alpine. Slim is still small but has a few extra things.


fra
HOBBY

3 months ago

mmm I wonder if it is because is a self signed, I've tried to connect via ssl in my app and I get:
Error: self-signed certificate in certificate chain

yet give in theory you would connect to the db using the internal network maybe the ssl is not really needed?

edit: using something like:

ssl: { rejectUnauthorized: false },

works, so I suppose the reason is because there is not a ca certificate but only a self signed one


noahd

Hey! Can you try switching to slim from alpine i have a theory that there might be something missing from alpine. Slim is still small but has a few extra things.

pbird
HOBBYOP

3 months ago

It is working now. Thank you


pbird

It is working now. Thank you

noahd
EMPLOYEE

3 months ago

Happy to help!


Status changed to Solved noahd 3 months ago


Loading...