Forrest logo
back to the pg_isready tool

pg_isready:tldr:7e502

pg_isready: Check connection displaying a message only when the connection fails.
$ pg_isready --quiet
try on your machine

The command "pg_isready --quiet" is used to check the status of a PostgreSQL database server and determine if it is accepting connections. Here is an explanation of the command and its options:

  • "pg_isready" is the name of the command-line utility that comes with PostgreSQL.
  • "--quiet" is an option that tells the command to run in a silent mode, without printing any additional information except the exit status.

By running "pg_isready --quiet", the command will attempt to connect to the local or remote database server and check if it is ready to accept connections. It will then print a short message indicating the current status:

  • "accepting connections" means that the server is up and running, and it is ready to accept connections.
  • "rejecting connections" means that the server is running but currently not accepting connections, usually due to being in a maintenance mode or other configuration settings.
  • "no response" means that the server is not accessible or not running.

The command is often used in scripts or automated monitoring to check the availability of a PostgreSQL database before performing any database operations. Since it runs silently with the "--quiet" option, the result can be easily used in conditional statements or further processing within the script.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the pg_isready tool