Independent technical referenceOfficial site
  • Software and digital services
  • Databases

08001

PostgreSQL 08001 database error: client cannot open connection

Verified with sources3 sourcesReviewed Oct 19, 2026
Technician coming? See the 2 steps they must show you
Trace

Risk level

Medium

Proceed carefully and stop if the check is unclear.

Urgency

Medium

Quick answer

SQLSTATE 08001 (sqlclient_unable_to_establish_sqlconnection) means the client driver could not open a session with the PostgreSQL server. Check host, port, and sslmode from the same runtime with pg_isready and record the exact libpq error before changing server configuration.

Safety first

Stop and check this first

  • Never edit pg_hba.conf to trust or disable TLS verification on untrusted networks just to work around 08001; trust allows anyone who can reach the server to log in as any PostgreSQL user without authentication.
  • Redact passwords, URI user:password credentials, and sslpassword values before sharing conninfo strings, pgpass files, or sslkeylogfile traces with support teams.

Safe checks you can perform

  • Run pg_isready from the same application host or container
  • Inspect parsed libpq connection parameters and PQerrorMessage output
  • Check listen_addresses, port, and ssl on the PostgreSQL server

Leave these tasks to a qualified professional

  • Do not attempt this professional task: Align postgresql.conf listener interfaces and firewall routing
  • Do not attempt this professional task: Configure server and client TLS certificates for verified sslmode

What a technician must be able to justify

Technician visit

These are the steps they must carry out and show you. Tick them as they work: if steps are skipped, do not accept a part swap.

These are not instructions for opening or handling the equipment yourself. They are the checks that should support a technical conclusion.

  1. Align postgresql.conf listener interfaces and firewall routing

    What they doHave the DBA or infrastructure engineer configure listen_addresses and port in postgresql.conf for the required network interface, verify network routing between client and server, and schedule a controlled server start if listener parameters changed.

    They must show youthe output of SHOW listen_addresses and SHOW port alongside a successful pg_isready response from the application subnet.

    In writingthe exact interface addresses enabled in postgresql.conf, the firewall rule reference, and the maintenance restart timestamp.

  2. Configure server and client TLS certificates for verified sslmode

    What they doHave the DBA and developer align server ssl, ssl_cert_file, and ssl_key_file settings with the client sslmode, sslrootcert, and hostname so TLS handshakes complete without weakening transport security.

    They must show youa connection test where PQsslInUse returns 1 and PQsslAttribute reports the negotiated TLS protocol and cipher.

    In writingthe configured sslmode, certificate authority path, and server ssl_min_protocol_version applied to the environment.

Before accepting a part or repair

Nothing has been shown yet. Do not accept a part swap based on the code alone.

Follow these steps

Note: Follow the documented order. An error code identifies the affected system, but it does not prove by itself which part has failed.

  1. Run pg_isready from the same application host or container

    Tools required

    Who:
    Your developer or platform administrator runs this read-only check from the failing client runtime.
    How:
    Execute pg_isready -h <hostname> -p <port> -t 3 using the exact host and port values configured in the application connection string.
    Result that matters:
    The utility reports exit status 0 when accepting connections, 1 when rejecting, 2 when there is no response within 3 seconds, or 3 when parameters are invalid.
    If the exit status is 2, that confirms no response arrived from the target endpoint and points to stopped server processes, a firewall block, or wrong listen_addresses and port settings.
    If the exit status is 0, that rules out a dead TCP listener and isolates the 08001 failure to client driver parameters, TLS verification, or session attribute filters.
    Evidence to keep:
    Save the exact pg_isready output line, numerical exit status, and timestamp with passwords redacted.

    Never include plaintext passwords in shared command history; pg_isready does not require valid credentials to report server status.

    Evidence: PostgreSQL database connection control functions · PostgreSQL 18 pg_isready

  2. Inspect parsed libpq connection parameters and PQerrorMessage output

    Tools required

    Who:
    Your application developer inspects the client configuration and error log.
    How:
    Review the active keyword/value conninfo or URI for host, hostaddr, port, dbname, sslmode, sslrootcert, and target_session_attrs, and read the full PQerrorMessage text when PQstatus returns CONNECTION_BAD.
    Result that matters:
    A missing host on Unix selects a local socket in /tmp, while sslrootcert=system forces verify-full and rejects weaker sslmode settings.
    If PQping returns PQPING_NO_ATTEMPT or pg_isready returns 3, that confirms client-side parameter syntax or local resource allocation failed before any network packet left the host.
    If the parameters resolve to the expected IP address and port yet CONNECTION_BAD persists during SSL startup, that points to an sslmode or certificate authority mismatch.
    Evidence to keep:
    Keep a redacted copy of the parsed connection string parameters and the complete multi-line PQerrorMessage text.

    Do not attempt to bypass TLS errors by switching production connections over untrusted networks to unencrypted password modes.

    Evidence: PostgreSQL database connection control functions · PostgreSQL 18 libpq connection status functions

  3. Check listen_addresses, port, and ssl on the PostgreSQL server

    Tools required

    Who:
    Your DBA or hosting administrator runs a read-only configuration query on the server.
    How:
    Connect locally on the database host and inspect listen_addresses, port, unix_socket_directories, and ssl in postgresql.conf or via SHOW commands.
    Result that matters:
    By default, listen_addresses is localhost and ssl is off, and changing listen_addresses or port requires a server restart to take effect.
    If listen_addresses is localhost or empty while the application connects over a remote network interface, that confirms the server is not listening on the interface targeted by 08001.
    If listen_addresses includes the target interface and port matches, that rules out local listener binding and points to intermediate network routing, security groups, or TLS certificate files.
    Evidence to keep:
    Record the current values of listen_addresses, port, and ssl along with the server interface IP list.

    Do not restart the production PostgreSQL service to change listen_addresses or port without scheduling a maintenance window.

    Evidence: PostgreSQL connection settings

Still not solved

If the error persists, stop here. See what the technician must do and show you.

Virtual technician

Does 08001 still appear after these checks?

This guided flow uses the exact code and your answers to choose a test, an expected result and the next branch.

Where this code applies

A code is meaningful only inside the right product and version context.

Primary scope

System
Software and digital services
Brand
PostgreSQL
Product type
Databases

Known code variants

  • PostgreSQL 08001
  • sqlclient_unable_to_establish_sqlconnection
  • SQLSTATE 08001

What it means

PostgreSQL Appendix A assigns 08001 to sqlclient_unable_to_establish_sqlconnection under Class 08 Connection Exception. The failure happens on the client connection path before any SQL query or transaction starts, involving libpq parameters (host, hostaddr, port, sslmode, sslrootcert, connect_timeout, target_session_attrs) or server network listeners (listen_addresses and port in postgresql.conf). By itself, code 08001 does not prove the database server is down or damaged, because a wrong socket path, firewall rule, DNS record, or TLS verification mismatch produces the same class 08 condition.

Warnings and stop conditions

  • Mediumsource verified

    Never edit pg_hba.conf to trust or disable TLS verification on untrusted networks just to work around 08001; trust allows anyone who can reach the server to log in as any PostgreSQL user without authentication.

    Evidence: PostgreSQL database connection control functions · PostgreSQL 18 the pg_hba.conf file

  • Lowsource verified

    Redact passwords, URI user:password credentials, and sslpassword values before sharing conninfo strings, pgpass files, or sslkeylogfile traces with support teams.

    Evidence: PostgreSQL database connection control functions

Symptoms and causes

Probable causes · in order

  • Server listening only on local loopback or Unix socketCommon

    In postgresql.conf, listen_addresses defaults to localhost, which accepts only local loopback TCP connections, and an empty value disables IP interfaces completely so remote clients cannot reach port 5432.

    Evidence: PostgreSQL connection settings · PostgreSQL 18 the pg_hba.conf file

  • Mismatched host, hostaddr, port, or Unix socket directory in conninfoCommon

    When host is omitted on Unix, libpq attempts a Unix domain socket in /tmp rather than TCP, and an incorrect host, hostaddr, or port parameter leaves PQping with PQPING_NO_RESPONSE or PQPING_NO_ATTEMPT.

    Evidence: PostgreSQL database connection control functions · PostgreSQL 18 pg_isready

  • TLS negotiation or sslrootcert verification failure during startupPossible

    Requesting sslmode=require, verify-ca, or verify-full when ssl is off on the server, or setting sslrootcert=system with a mode weaker than verify-full, causes libpq to abort connection establishment.

    Evidence: PostgreSQL database connection control functions · PostgreSQL connection settings

  • Target session attributes or connect_timeout exhausted across hostsPossible

    If target_session_attrs requires read-write or primary while all listed hosts are in hot standby, or if connect_timeout expires before the TCP handshake completes, the client reports 08001.

    Evidence: PostgreSQL database connection control functions · PostgreSQL 18 libpq connection status functions

Sources and technical references

  1. 1

    PostgreSQL 18 Appendix A: Error Codes

    PostgreSQL Global Development Group · 2026 · official_doc

  2. 2

    PostgreSQL error and notice fields

    PostgreSQL Global Development Group · 2026 · official_doc

  3. 3

    PostgreSQL database connection control functions

    PostgreSQL Global Development Group · 2026 · official_doc

Sources: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL error and notice fields · PostgreSQL database connection control functionsreviewed 2026-10-19 · verified

Was this entry useful?