PG_ISREADY(1)

πŸ“¦ version 17.11, in opensuse-leap 16.0

✨ PG_ISREADY(1) ✨

okay bestie, this is pg_isready β€” it's the little PostgreSQL utility from the PostgreSQL 17.11 docs that tells you whether a server is up and vibing πŸ’…


πŸ’– NAME πŸ’–

pg_isready β€” literally just checks the connection status of a PostgreSQL server. that's it. that's the whole job πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

pg_isready [connection-option...] [option...]

so you run it, you throw some connection options at it, maybe some regular options, and it reports back 🌸


🌈 DESCRIPTION 🌈

pg_isready is a utility for checking the connection status of a PostgreSQL database server. and like β€” the whole result of the connection check comes back to you as the exit status, so pay attention to $?, okay? that's where the tea is πŸ‘‘


✨ OPTIONS ✨

  • -d dbname, --dbname=dbname β€” specifies the name of the database to connect to. plot twist: dbname can be a connection string, and if it is, any connection string parameters in there will override conflicting command line options. she overrides. periodt πŸ’…
  • -h hostname, --host=hostname β€” specifies the host name of the machine on which the server is running. and if the value starts with a slash, it's used as the directory for the Unix-domain socket. sneaky but iconic πŸ¦‹
  • -p port, --port=port β€” specifies the TCP port, or the local Unix-domain socket file extension, that the server is listening on for connections. defaults to the value of the PGPORT environment variable or, if that's not set, to the port specified at compile time, usually 5432 ✨
  • -q, --quiet β€” do not display the status message. so useful when you're scripting, because nobody wants extra noise in their logs πŸ™ˆ
  • -t seconds, --timeout=seconds β€” the maximum number of seconds to wait when attempting connection before returning that the server is not responding. setting it to 0 disables the timeout entirely. default is 3 seconds ⭐
  • -U username, --username=username β€” connect to the database as the user username instead of the default 🫢
  • -V, --version β€” print the pg_isready version and exit. bye πŸ‘‹
  • -?, --help β€” show help about pg_isready command line arguments, and exit. also bye πŸ‘‹

πŸ”₯ EXIT STATUS πŸ”₯

this is the main character section honestly, so let's go:

  • 0 β€” returned to the shell if the server is accepting connections normally. slay πŸŽ‰
  • 1 β€” returned if the server is rejecting connections (for example during startup). she's still loading 😭
  • 2 β€” returned if there was no response to the connection attempt πŸ’€
  • 3 β€” returned if no attempt was made (for example due to invalid parameters). fair enough πŸ™ˆ

🌸 ENVIRONMENT 🌸

pg_isready, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15). iykyk 🧚

the environment variable PG_COLOR specifies whether to use color in diagnostic messages. possible values are always, auto and never. yes queen, aesthetic diagnostics πŸ’œ


πŸŽ€ NOTES πŸŽ€

big one: it is not necessary to supply correct user name, password, or database name values to obtain the server status. so you don't have to get your credentials right just to vibe check the server πŸ¦‹

but heads up β€” if incorrect values are provided, the server will log a failed connection attempt. so like, your DBA might see it. no cap πŸ‘€

⭐ EXAMPLES ⭐

Standard usage:

$ pg_isready
/tmp:5432 - accepting connections
$ echo $?
0

Running with connection parameters to a PostgreSQL cluster in startup:

$ pg_isready -h localhost -p 5433
localhost:5433 - rejecting connections
$ echo $?
1

Running with connection parameters to a non-responsive PostgreSQL cluster:

$ pg_isready -h someremotehost
someremotehost:5432 - no response
$ echo $?
2

and that's the whole page bestie, go check some servers πŸ’–

🌈 sign-off: brought to you by PostgreSQL 17.11, dated 2026. PG_ISREADY(1) out. 🫢
πŸ“¦ where this page comes from