You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sql client instances handle ECONNREFUSED errors inconsistently. This error is thrown when the database is unreachable. In the steps below, I am in control of the postgres process. I would think the same steps work with network access as well.
Client uses sql instance to run queries. These fail, as expected. Node throws this error, ONCE:
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1592:16)
at cachedError (file:///Users/matt/Projects/pg-test/node_modules/postgres/src/query.js:171:23)
at new Query (file:///Users/matt/Projects/pg-test/node_modules/postgres/src/query.js:36:24)
at sql (file:///Users/matt/Projects/pg-test/node_modules/postgres/src/index.js:111:11)
at Function.listen (file:///Users/matt/Projects/pg-test/node_modules/postgres/src/index.js:179:35)
Launch Postgres.
Client uses sql instance to run queries. These fail. This is unlike the first set of steps, where the connection is re-established and queries proceed as normal.
So should they behave the same? If this is expected behaviour, what is the right pattern to use to keep the sql instance valid?
Activity
porsager commentedon Jul 15, 2023
Very nice description ! That is definitely not intended, I'll see if I can find some time to repro and look into it.
mattbishop commentedon Oct 29, 2023
I test this issue with every release, and it is still present in v3.4.2
micalevisk commentedon Dec 5, 2025
@mattbishop does v3.4.7 fixed it?
mattbishop commentedon Dec 5, 2025
So this issue appears to be resolved now with 3.4.7. Thanks for the reminder to check.