2 months ago
Need a single, prescriptive fix for Postgres read ECONNRESET on public DB URLs (delete one row)
Context: I run a maintenance job that connects to ~15 PostgreSQL databases on Railway to delete a single row in a table by URL:
DELETE FROM auctions WHERE link = $1;
Behavior: Most DBs work, but two specific DBs intermittently fail with read ECONNRESET. This happens locally and on Railway. We are using the public database URL because the app and these databases are in different Railway projects.
What’s already implemented (still fails on those two DBs):
Tried pg (Client and Pool) and Sequelize v6 (postgres dialect).
Public pooled vs direct endpoints,
keepAlive: true, limited concurrency, retries with backoff,SELECT 1preflight,SET statement_timeout '30s'.SSL variations:
sslmode=no-verify,rejectUnauthorized:false.Fallback flow that opens a brand-new pg Client per attempt (connect → ping → delete → end) for the two problematic DBs, processed sequentially.
Restarts of the DB services. Postgres logs have included:
invalid length of startup packet,could not receive data from client: Connection reset by peer, and previouslyCERT_HAS_EXPIRED.
Request: Provide one supported, prescriptive solution that ensures a stable connection over public URLs across projects so this single-row DELETE completes reliably without ECONNRESET—including the exact endpoint type to use and the precise connection string/flags or server-side configuration required.
2 Replies
2 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!
2 months ago
Hmm, I'd say either your connection pooling mode or the fact that you're going over public networking and firing this to a bunch of databases simultaneously is leading to Postgres dumping your connection. I'd suggest trying to use your maintenance job on a private network, and seeing if that gets you more stability. You may also want to check your connection pooler's logs to see precisely what the issue is (the logs you provided aren't really detailed enough to see what's going on)
That said, this appears to be an issue with your application. Are you seeing other problems that would point to something wrong with Railway's infrastructure itself?
Status changed to Awaiting User Response Railway • 2 months ago
Status changed to Solved luiskurihara • 2 months ago