Postgres ECONNRESET / unable to connect using TCP Proxy

julientregoat
FREE

4 months ago

Hi there,

I've had a great experience with Railway so far, but I'm encountering one issue I can't seem to find a fix for.

Whenever I try to connect to my Postgres service via the TCP Proxy, it never connects.

I have tried using both psql and railway connect (which I guess uses psql under the hood) and get the same error:
```
psql: error: connection to server at "<redacted>" (<redacted>), port <redacted> failed: server closed the connection unexpectedly

This probably means the server terminated abnormally

before or while processing the request.
```

I am able to connect to the image via railway ssh but this doesn't help me if I'm trying to run migrations from my local computer. I imagine a hacky workaround could be to SSH into my backend service and install the required dependencies to migrate from that instance using private networking, but I don't love that idea and it's a bit restrictive.

It seems like other people have encountered this issue with Railway but no clear solution was found in my research other than to add a 3 second timeout, but not sure how that would work if I'm using a CLI that doesn't expose that as a configuration option.

Is there some reason the server would keep aborting the connection? Am I using the TCP proxy incorrectly?

Awaiting User Response

5 Replies

4 months ago

Are you using DATABASE_PUBLIC_URL to connect ?


Status changed to Awaiting User Response Railway 4 months ago


julientregoat
FREE

4 months ago

yes I am! I’m using referenced variables for everything


Status changed to Awaiting Railway Response Railway 4 months ago


4 months ago

That's odd. Are you able to try re-deploying the database? Was the TCP Proxy added manually?


Status changed to Awaiting User Response Railway 4 months ago


ray-chen

That's odd. Are you able to try re-deploying the database? Was the TCP Proxy added manually?

julientregoat
FREE

4 months ago

yes I added the TCP proxy manually. I am going to redeploy the database but this isn't viable in production, correct?


Status changed to Awaiting Railway Response Railway 4 months ago


4 months ago

Hello,

I am noticing that the Data tab can load the tables just fine, the Data tab connects via the public network, so if that works, the issue may be with your own network.


Status changed to Awaiting User Response Railway 4 months ago


Postgres ECONNRESET / unable to connect using TCP Proxy - Railway Help Station