SQLSTATE 24000 ERROR Class 24: Invalid Cursor State

invalid_cursor_state portal “…” does not return tuples — 24000

PostgreSQL error “portal “…” does not return tuples” (SQLSTATE 24000, invalid_cursor_state): what it means, common causes, and how to fix it.

PG 15, 16, 17, 18, 19 Official docs
Last reviewed Jun 2026 Grounded in source
Production impact Low Competency Transactions & Isolation Career Pass Senior DBA interviews Frequency Rare

Investigation

Symptoms

A statement failed with SQLSTATE 24000 (invalid_cursor_state), reported at severity ERROR. This is a Invalid Cursor State condition: PostgreSQL emits the message portal "…" does not return tuples.

  • The client receives SQLSTATE 24000 (invalid cursor state).
  • The operation is rejected at ERROR level; the statement does not complete.

What the server log shows

ERROR:  portal "…" does not return tuples

Why PostgreSQL raises this

PostgreSQL raises this error from the area indicated by its SQLSTATE class. The condition name pinpoints the specific rule that was violated.

As described in PostgreSQL’s Appendix A PostgreSQL Error Codes, SQLSTATE 24000 carries the condition name invalid_cursor_state in class Invalid Cursor State. (Paraphrased — see the linked reference for the exact wording.)

Common causes

  • The operation violated the rule named by this SQLSTATE condition.
  • An input, object, or state did not satisfy a precondition.

How to fix it

  1. Use the SQLSTATE condition name to identify the exact rule.
  2. Correct the offending input, object, or state and retry.
  3. See the linked full SQLSTATE reference for detailed guidance.

Version applicability

This message is present in PostgreSQL 15, 16, 17, 18 and 19.

Related & next steps

Reference: PostgreSQL Appendix A PostgreSQL Error Codes.

Keep going

Related & next steps

Concepts on this page

Was this helpful?