Diagnostic Queries
Symptoms
An SSL/TLS-encrypted connection was closed unexpectedly without a clean shutdown. The driver reports SQLSTATE 08006 (connection_failure).
- The encrypted connection dropped abnormally.
- Often a backend crash/restart or network drop on a TLS session.
- Distinct from a TLS negotiation failure.
What the server log shows
SSL connection has been closed unexpectedly
Why PostgreSQL raises this — what the manual says
As Section 18.9 Secure TCP/IP Connections with SSL explains:
An encrypted (SSL/TLS) connection was torn down without a clean close-notify handshake — commonly caused by the peer process crashing, a network drop, or an idle/keepalive timeout closing the socket mid-session.
On a TLS connection, an abrupt break (without a proper close-notify) leaves the SSL session terminated unexpectedly. The client cannot continue and reports 08006.
Common causes
- A backend crash, restart, or failover on a TLS session.
- Network instability or a middlebox resetting the connection.
- TLS renegotiation/timeouts on long-idle encrypted sessions.
How to fix it
- Reconnect and retry; handle dropped encrypted connections gracefully.
- Check the server log for crashes/terminations.
- Investigate network devices/load balancers and keepalive/idle settings.
Related & next steps
Reference: PostgreSQL 18 Section 19.9 “SSL”.
Thanks — noted. This helps keep the database accurate.