ERROR: canceling statement due to statement timeout
A query ran longer than statement_timeout and PostgreSQL cancelled it.
Seen on:
PostgreSQL
Meaning
Timeouts are set per role/database/session (often by hosting providers or ORMs). Missing indexes and huge scans are the usual root cause.
Common causes
- Slow query (missing index, large scan)
- statement_timeout set low by provider/role
- Lock waits counted in the duration
⚡ Quick fix
- EXPLAIN ANALYZE the query and add indexes
- Raise statement_timeout for specific jobs: SET statement_timeout = '5min'
- Batch large operations
Detailed fix by platform
PostgreSQL
EXPLAIN (ANALYZE, BUFFERS) SELECT …;
How to diagnose
- Query — How long does it take?
- Timeout — SHOW statement_timeout
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 3 Oct 2026