Skip to content

feat(connection): support comma-separated multi-host for failover (psql parity) #724

@NikolayS

Description

@NikolayS

Problem

psql supports comma-separated hostnames for automatic failover:

psql -h "host1,host2,host3" -p 5432 -U postgres -c "SELECT 1"

rpg treats the entire comma-separated string as a single hostname, sends it to DNS, and fails.

Expected

rpg should parse comma-separated hosts and try each in sequence, connecting to the first that succeeds. This is standard libpq behavior and is commonly used for HA setups with a primary and one or more standbys.

psql docs reference

If host is a comma-separated list of host names, each will be tried in the given order.

Acceptance criteria

  • -h "host1,host2" tries host1 first, falls back to host2
  • PGHOST=host1,host2 same behavior
  • host=host1,host2 in connstring same behavior
  • postgres://host1,host2/db URI form same behavior
  • Stops at first successful connection
  • Error message lists all tried hosts if all fail

Discovered

Full connection matrix audit, 2026-03-24 (Section F, F5).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions