PostgreSQL: server closed the connection unexpectedly

server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

The TCP connection ended without a proper protocol goodbye. Two very different families of causes produce this identical client message: something killed the server side (crash, restart, out-of-memory), or a network middlebox silently dropped an idle connection. One check separates them: the server log at that timestamp.

What this error means

Read the server log for the moment of the disconnect:

Common causes

How to diagnose it

How to fix it

🔍 The connect-time cousin: Connection refused — when the connection never gets established at all.