BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`

Started by PG Bug reporting form9 months ago4 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 19002
Logged by: Samuel Marks
Email address: samuelmarks@gmail.com
PostgreSQL version: 17.5
Operating system: macOS
Description:

```
/ > 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)

#2Jacob Champion
jacob.champion@enterprisedb.com
In reply to: PG Bug reporting form (#1)
Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`

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]https://www.postgresql.org/docs/current/app-pg-isready.html#APP-PG-ISREADY-NOTES:

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

#3Samuel Marks
samuelmarks@gmail.com
In reply to: Jacob Champion (#2)
Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`

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…

Samuel Marks
Charity <https://sydneyscientific.org&gt; | consultancy <https://offscale.io&gt;
| open-source <https://github.com/offscale&gt; | LinkedIn
<https://linkedin.com/in/samuelmarks&gt;

On Tue, Jul 29, 2025 at 2:54 PM Jacob Champion <
jacob.champion@enterprisedb.com> wrote:

Show quoted text

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Samuel Marks (#3)
Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`

Samuel Marks <samuelmarks@gmail.com> writes:

Hmm I suppose that works, but really I was using it as a "can i connect"
check.

That's explicitly not its job. Why don't you just try to connect?
Or if you want a command-line tool, consider

psql ...connection options... -c 'select 1'

regards, tom lane