Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username` - Mailing list pgsql-bugs

From Samuel Marks
Subject Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`
Date
Msg-id CAMfPbcY+9YR6y+8qyn5SziO8--qBjGzBQO4A-PG=Q9zYmoyL1w@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`  (Jacob Champion <jacob.champion@enterprisedb.com>)
Responses Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`
List pgsql-bugs
Hmm I suppose that works, but really I was using it as a "can i connect" check. Similar to https://github.com/eficode/wait-for or https://github.com/wait4x/wait4x

It seems weird—unexpected to user—to accept dbname or user and not have a non-zero exit code or something in stderr indicating failure…


On Tue, Jul 29, 2025 at 2:54 PM Jacob Champion <jacob.champion@enterprisedb.com> wrote:
On Tue, Jul 29, 2025 at 12:45 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
> /  > pg_isready -U fff
> /tmp:5432 - accepting connections
> /  > pg_isready -U fff -d555
> /tmp:5432 - accepting connections
> ```
>
> (`fff` is not a user and `555` is not a db on my installation)

Hi Samuel, this behavior is explained in the docs [1]:

> It is not necessary to supply correct user name, password, or database name values to obtain the server status; however, if incorrect values are provided, the server will log a failed connection attempt.

So it's essentially just a courtesy to whoever's watching your logs.

--Jacob

[1] https://www.postgresql.org/docs/current/app-pg-isready.html#APP-PG-ISREADY-NOTES

pgsql-bugs by date:

Previous
From: Jeff Davis
Date:
Subject: CREATE DATABASE copies datlocale even if datlocprovider differs
Next
From: shveta malik
Date:
Subject: Re: Unexpected Standby Shutdown on sync_replication_slots change