PG_ISREADY(1)
π pg_isready β check the connection status of a PostgreSQL server
okay bestie, so this is the pg_isready page from the PostgreSQL 14.24 docs, and honestly? it's giving "tiny utility, huge main character energy" β¨ she's a whole vibe check for your database server and she does exactly one thing but she does it flawlessly π
πΈ SYNOPSIS πΈ
pg_isready [connection-option...] [option...]
β¨ DESCRIPTION β¨
so pg_isready is this adorable little utility that just... checks the connection status of a PostgreSQL database server π«Ά that's it, that's the job, and she ate. the actual result of the check comes back through the exit status, which is literally the whole point β so if you're scripting, this is your girl π
π OPTIONS π
-ddbname,--dbname=dbnameβ tells her which database to connect to, bestie. and here's the slay part: dbname can be a connection string, and if it is, then those connection string parameters override any conflicting command line options. no cap, they win π-hhostname,--host=hostnameβ names the host of the machine the server is running on π and if the value starts with a slash, it gets used as the directory for the Unix-domain socket. cute little detail, love that for us.-pport,--port=portβ the TCP port, or the local Unix-domain socket file extension, that the server is listening on for connections β¨ defaults to whateverPGPORTenvironment variable says, or if that's not set, the port specified at compile time β usually5432β-q,--quietβ do not display the status message π super useful when you're scripting, because sometimes you just want the exit status and zero chatter, iykyk.-tseconds,--timeout=secondsβ the max number of seconds to wait while attempting the connection before it comes back with "the server is not responding" π setting it to0disables the timeout entirely. the default is3seconds.-Uusername,--username=usernameβ connect to the database as the user username instead of the default π¦-V,--versionβ print thepg_isreadyversion and exit, periodt π-?,--helpβ show help aboutpg_isreadycommand line arguments, and exit π
π₯ EXIT STATUS π₯
this is the part that matters most, so pay attention bestie π pg_isready returns:
0to the shell if the server is accepting connections normally π1if the server is rejecting connections (for example during startup) π₯²2if there was no response to the connection attempt π3if no attempt was made at all (for example due to invalid parameters) π
π ENVIRONMENT π
pg_isready, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15) π«Ά
the environment variable PG_COLOR specifies whether to use color in diagnostic messages π possible values are always, auto and never.
π¦ NOTES π¦
okay so here's the tea: it is not necessary to supply correct user name, password, or database name values to obtain the server status π like, she'll still tell you what's up. BUT β and this is the important bit β if incorrect values are provided, the server will log a failed connection attempt π so maybe don't spam it with nonsense unless you're fine with your logs being messy.
π EXAMPLES π
Standard usage, the classic, the icon:
$ pg_isready
/tmp:5432 - accepting connections
$ echo $?
0
Running with connection parameters to a PostgreSQL cluster in startup β she's rejecting, bless her, she's still booting:
$ pg_isready -h localhost -p 5433
localhost:5433 - rejecting connections
$ echo $?
1
Running with connection parameters to a non-responsive PostgreSQL cluster β crickets, absolutely nothing, no response:
$ pg_isready -h someremotehost
someremotehost:5432 - no response
$ echo $?
2
and that's the whole page, bestie π no extra lore, no secret options, just the exact same facts dressed up cute π this was the pg_isready page from the PostgreSQL 14.24 docs, dated 2026 β go check your server's vibe, she's waiting π¦β¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms