PG_ISREADY(1)

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

πŸ’– PG_ISREADY(1) πŸ’–

okay bestie, welcome to the pg_isready page β€” it's a PostgreSQL 18.6 situation and honestly? she's a little legend. she's a command-line utility that just checks the vibe of a PostgreSQL server: is it up, is it taking connections, is it ghosting us. and she tells you the answer through her exit status, which is the most main-character way to communicate, periodt. 🫢


✨ NAME ✨

pg_isready β€” check the connection status of a PostgreSQL server πŸ’…


🌸 SYNOPSIS 🌸

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, pg_isready is a utility for checking the connection status of a PostgreSQL database server. that's it, that's the job, she's not complicated, she's just reliable. πŸ’–

the way she reports back? through her exit status. no paragraphs, no essay, just a number that says everything. iykyk. ✨


πŸŽ€ OPTIONS πŸŽ€

  • -d dbname, --dbname=dbname β€” tells her which database to connect to, bestie. and plot twist: dbname can be a connection string πŸ‘€ and if it is, those connection string parameters will override any conflicting command line options. she said the string wins, no cap.
  • -h hostname, --host=hostname β€” the host name of the machine where the server is running. cute detail: if the value starts with a slash /, she treats it as the directory for the Unix-domain socket. very demure, very mindful. 🧚
  • -p port, --port=port β€” the TCP port, or the local Unix-domain socket file extension, where the server is listening for connections. defaults to the value of the PGPORT environment variable or, if that's not set, to the port specified at compile time, which is usually 5432. she's got backup plans for her backup plans. πŸ’…
  • -q, --quiet β€” do not display status message. this is useful when scripting. lowkey the introvert option, she just silently does her job. 🀫
  • -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. the default is 3 seconds. she will NOT wait around forever for a man. ⏳
  • -U username, --username=username β€” connect to the database as the user username instead of the default. choose your fighter. πŸ‘‘
  • -V, --version β€” print the pg_isready version and exit. quick lil flex, then she's out. ✨
  • -?, --help β€” show help about pg_isready command line arguments, and exit. she's happy to explain herself. 🫢

πŸ”₯ EXIT STATUS πŸ”₯

here's the part you actually came for, the receipts, the numbers, the vibe check results:

  • 0 β€” the server is accepting connections normally. she ate. πŸ’š
  • 1 β€” the server is rejecting connections (for example during startup). she's awake but she's not ready to talk yet. 😭
  • 2 β€” there was no response to the connection attempt. literally silence. πŸ’€
  • 3 β€” no attempt was made at all (for example due to invalid parameters). not me showing up with the wrong address. πŸ™ˆ

🌈 ENVIRONMENT 🌈

pg_isready, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15). she's plugged into the whole ecosystem, she's not doing her own thing.

the environment variable PG_COLOR specifies whether to use color in diagnostic messages. possible values are always, auto and never. pick your aesthetic. 🎨


πŸ’œ NOTES πŸ’œ

it is not necessary to supply correct user name, password, or database name values to obtain the server status. she just needs to know if the server's there. BUT β€” and this is the important bit, bestie β€” if incorrect values are provided, the server will log a failed connection attempt. so like, the server is watching. πŸ‘€

πŸ“ EXAMPLES πŸ“

standard usage, the classic, the everyday slay:

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

running with connection parameters to a PostgreSQL cluster in startup (she's still getting ready, give her a minute):

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

running with connection parameters to a non-responsive PostgreSQL cluster (left on read, unfortunately):

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

and that's the whole page, bestie! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

this was PG_ISREADY(1) from the PostgreSQL 18.6 documentation, dated 2026 β€” she's iconic, she's timeless, she's checking connections since forever. go forth and echo $? responsibly. periodt. πŸ‘‘πŸ’…πŸ«Ά

πŸ“¦ where this page comes from