SQLSTATE 57014 ERROR Class 57: Operator Intervention

query_canceled canceling statement due to user request — 57014

PostgreSQL error "canceling statement due to user request" (SQLSTATE 57014): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A running statement was cancelled because something sent a cancel request — a user pressing Ctrl-C, an application statement timeout, or pg_cancel_backend(). PostgreSQL raises SQLSTATE 57014 (query_canceled).

  • The query stops mid-execution and rolls back its work.
  • Triggered by client cancel, admin cancel, or a timeout.
  • Distinct from termination — the connection survives.

What the server log shows

ERROR:  canceling statement due to user request

Why PostgreSQL raises this — what the manual says

Section 9.28.2 Server Signaling Functions:

“Cancels the current query of the session whose backend process has the specified process ID.”

A cancel request sets a flag the backend checks at safe interrupt points. On the next check the backend aborts the current statement with 57014 and rolls back its in-flight work, leaving the session open.

Common causes

  • A user cancelled the query (Ctrl-C in psql).
  • An admin ran pg_cancel_backend(pid).
  • Application or driver cancellation (e.g. a client-side timeout).

How to fix it

  1. If unintended, investigate which client/timeout issued the cancel.
  2. Tune client/statement timeouts if cancellations are premature.
  3. For runaway queries, prefer cancel over terminate to keep the session alive.

Related & next steps

Reference: PostgreSQL 18 Section 9.28 “System Administration Functions”.

Was this helpful?