DBAtlas · Database operations atlas

Terminate a backend (pg_terminate_backend)

PostgreSQLSessions

Command

SELECT pg_terminate_backend(12345);

What it does

Forcibly terminates the backend process with the given PID; drops the connection and the running transaction.

When to use it

To close a stuck/hung connection or a session holding a lock.

Caution

The running transaction is rolled back; uncommitted work is lost. Try the gentler pg_cancel_backend first. Verify the PID in pg_stat_activity.

Open in DBAtlas →

Related