↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

57P03 — cannot_connect_now

57P03 is emitted during connection startup when the database has not reached a connection-ready state. Fixed guards distinguish startup, shutdown, recovery, disabled hot standby, and two different not-yet-consistent recovery states.

English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

aliases
Unknown
class name
Operator Intervention
condition name
cannot_connect_now
lang
en
sqlstate
57P03

Definition PG 18

57P03

At a glance {#at-a-glance}

57P03 is emitted during connection startup when the database has not reached a connection-ready state. Fixed guards distinguish startup, shutdown, recovery, disabled hot standby, and two different not-yet-consistent recovery states.

Meaning {#meaning}

The startup packet is rejected before normal authentication is completed. Every fixed branch uses FATAL, so the attempted connection ends rather than entering a client transaction. The primary alone is not enough for the hot-standby branches: detail distinguishes a disabled feature, a recovery snapshot that is not ready, and recovery that has not reached a consistent state.

Messages {#messages}

  • Startup gate: primary the database system is starting up, FATAL.
  • Hot standby disabled: primary the database system is not accepting connections, FATAL; detail Hot standby mode is disabled.
  • Recovery snapshot not ready: primary the database system is not yet accepting connections, FATAL; detail Recovery snapshot is not yet ready for hot standby.; hint To enable hot standby, close write transactions with more than %d subtransactions on the primary server.
  • Recovery not consistent: primary the database system is not yet accepting connections, FATAL; detail Consistent recovery state has not been yet reached.
  • Shutdown gate: primary the database system is shutting down, FATAL.
  • Recovery gate: primary the database system is in recovery mode, FATAL.

Diagnosis {#diagnosis}

Capture primary/detail/hint, the startup phase, hot-standby setting, recovery consistency/snapshot state, server readiness log, and target server role. A repeated not yet accepting response with the snapshot detail points to the primary-side subtransaction condition named by the hint; the consistent-recovery detail points to an earlier recovery gate. Do not treat these as a transaction stuck in INERROR: the connection was refused before a session transaction existed.

Response {#response}

Use bounded backoff and wait for the relevant startup, shutdown, or recovery transition. If hot standby is intentionally disabled, remember that hot_standby is a PGC_POSTMASTER setting: change the configuration source owned by the server and restart the server; a SIGHUP/reload cannot activate this setting. If the hint identifies long primary write transactions, resolve that operational cause. Establish a new connection after readiness. There is no transaction on the rejected startup path to roll back; if a prior client operation was disconnected during a transition, verify its business result before replaying it.

Versions {#versions}

The locked catalogue records this condition from 7.4; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

Related {#related}

57P01, 57P04, 08001

Sources {#sources}

src/backend/tcop/backend_startup.c#L298-338

src/backend/utils/misc/guc_tables.c#L1895-1903

The structured evidence record records all fixed startup gates and the source/runtime boundary.

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "57P03 is cannot_connect_now in SQLSTATE Class 57."
}
claims · resolved-paths
{
  "claim_id": "resolved-paths",
  "limits": "Source confirmation is not natural runtime.",
  "method": "Read the complete startup guard and hot_standby GUC definition.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1"
  ],
  "statement": "The fixed startup guards support all listed startup/recovery messages, and guc_tables.c defines hot_standby as PGC_POSTMASTER, so enabling it requires a server restart rather than a reload."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 57P03 from 7.4; that boundary does not prove exact implementation introduction."
}
claims · hot-standby-context
{
  "claim_id": "hot-standby-context",
  "limits": "",
  "method": "Read the fixed guc_tables.c entry.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.path.1"
  ],
  "statement": "hot_standby has GUC context PGC_POSTMASTER; a SIGHUP/reload cannot activate a changed value for the running server."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.0",
    "primary_template": "the database system is starting up",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "57P03"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "the database system is starting up",
      "position": 0,
      "role": "",
      "template": "the database system is starting up"
    }
  ]
}
messages · message.1
{
  "limits": "",
  "message_id": "message.1",
  "path": "",
  "position": 1,
  "raw": {
    "detail_template": "Hot standby mode is disabled.",
    "id": "message.1",
    "primary_template": "the database system is not accepting connections",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "57P03"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "the database system is not accepting connections",
      "position": 0,
      "role": "",
      "template": "the database system is not accepting connections"
    },
    {
      "kind": "detail",
      "literal": "Hot standby mode is disabled.",
      "position": 1,
      "role": "",
      "template": "Hot standby mode is disabled."
    }
  ]
}
messages · message.2
{
  "limits": "",
  "message_id": "message.2",
  "path": "",
  "position": 2,
  "raw": {
    "detail_template": "Recovery snapshot is not yet ready for hot standby.",
    "hint_template": "To enable hot standby, close write transactions with more than %d subtransactions on the primary server.",
    "id": "message.2",
    "primary_template": "the database system is not yet accepting connections",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "57P03"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "the database system is not yet accepting connections",
      "position": 0,
      "role": "",
      "template": "the database system is not yet accepting connections"
    },
    {
      "kind": "detail",
      "literal": "Recovery snapshot is not yet ready for hot standby.",
      "position": 1,
      "role": "",
      "template": "Recovery snapshot is not yet ready for hot standby."
    },
    {
      "kind": "hint",
      "literal": "To enable hot standby, close write transactions with more than subtransactions on the primary server.",
      "position": 2,
      "role": "",
      "template": "To enable hot standby, close write transactions with more than %d subtransactions on the primary server."
    }
  ]
}
messages · message.3
{
  "limits": "",
  "message_id": "message.3",
  "path": "",
  "position": 3,
  "raw": {
    "detail_template": "Consistent recovery state has not been yet reached.",
    "id": "message.3",
    "primary_template": "the database system is not yet accepting connections",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "57P03"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "the database system is not yet accepting connections",
      "position": 0,
      "role": "",
      "template": "the database system is not yet accepting connections"
    },
    {
      "kind": "detail",
      "literal": "Consistent recovery state has not been yet reached.",
      "position": 1,
      "role": "",
      "template": "Consistent recovery state has not been yet reached."
    }
  ]
}
messages · message.4
{
  "limits": "",
  "message_id": "message.4",
  "path": "",
  "position": 4,
  "raw": {
    "id": "message.4",
    "primary_template": "the database system is shutting down",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "57P03"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "the database system is shutting down",
      "position": 0,
      "role": "",
      "template": "the database system is shutting down"
    }
  ]
}
messages · message.5
{
  "limits": "",
  "message_id": "message.5",
  "path": "",
  "position": 5,
  "raw": {
    "id": "message.5",
    "primary_template": "the database system is in recovery mode",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "57P03"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "the database system is in recovery mode",
      "position": 0,
      "role": "",
      "template": "the database system is in recovery mode"
    }
  ]
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L437"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/backend_startup.c",
  "position": 1,
  "sha256": "5516f3d6d83ae6fc66ca6bad9a7cea3cd2f8de53f0597c26baa2bd224ac270bb",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/backend_startup.c#L307"
}
sources · src.path.1
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/misc/guc_tables.c",
  "position": 2,
  "sha256": "7b3b81dcfd95f6543b01b2dd4262e93d03113065e18ed8f780b7125a4976e8df",
  "source_id": "src.path.1",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/misc/guc_tables.c#L1895"
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:986afd11fc48803fba07d18c5f343b5e645a6c45b47903a3e3e8f2cd5c88a6e8

Text language: en · english-manuals:986afd11fc48803fba07d18c5f343b5e645a6c45b47903a3e3e8f2cd5c88a6e8