Node-postgres: "Client has encountered a connection error and is not queryable" without further info

Created on 14 Dec 2018  路  7Comments  路  Source: brianc/node-postgres

Since upgrading from pg 7.4.1 to pg 7.7.1, we are getting "Client has encountered a connection error and is not queryable" error in production after a week of working just fine, but no additional information is being logged that could help us determine what the underlying issue is.

I believe this may have been caused by the changes in https://github.com/brianc/node-postgres/commit/3828aa86081491282c118884c245b4a19619f02e.

Expected behavior: also log the error reason.

Most helpful comment

I also see this error with plain pg lib (without using TypeORM or any other orm).
as @charmander said, an 'error' event is emmited.

pool.on('error',...)

but it is emmited only once, while the Client has encountered a connection error and is not queryable is printed everytime I use the defectuous pool

in my case, the emmited error was

Connection terminated unexpectedly Error: Connection terminated unexpectedly

in my case, this happened because of a network reset.
In some other situations, I had the impression that pool was resilient to connection loss, but I guess it's not always the case.

All 7 comments

The reason will have been emitted as an 'error' event on the client (and on the pool as well, if you鈥檙e using a pool).

hello I have a similar issue: I got a Pool that is not queryable and any error logged. I cant catch this error regardless of what I do.
got pg 7.7.1 and postgresql 9.6
I think these versions are incompatible. I will try to install postgresql 11

I'm having this problem too. In my case I am using version 7.7.1 with typeorm

@charmander Ok thanks! Seems I just missed it in our application logs since it was logged several hours before the "Client has encountered a connection error and is not queryable" message in each case.

Maybe it would make sense to include a copy of the reason along with the "Client has encountered a connection error and is not queryable" message, just for easier debugging?

For the record, we're using TypeORM and a pool.

Anyway, from our side, this issue can be closed. Thanks for the quick help!

I also see this error with plain pg lib (without using TypeORM or any other orm).
as @charmander said, an 'error' event is emmited.

pool.on('error',...)

but it is emmited only once, while the Client has encountered a connection error and is not queryable is printed everytime I use the defectuous pool

in my case, the emmited error was

Connection terminated unexpectedly Error: Connection terminated unexpectedly

in my case, this happened because of a network reset.
In some other situations, I had the impression that pool was resilient to connection loss, but I guess it's not always the case.

@rvion I'm currently seeing a similar issue, the error "Connection terminated unexpectedly" has come up, afterwards the connection was not queryable anymore ("Client has encountered a connection error and is not queryable".

May I ask how you approached this problem?

How about adding a helper method for auto-reconnecting whenever this happens?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spollack picture spollack  路  4Comments

dindurthy picture dindurthy  路  4Comments

gajus picture gajus  路  4Comments

gregallenvt picture gregallenvt  路  3Comments

v1co1n picture v1co1n  路  4Comments