Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/pg_isready.sgml`
193e0cfcf71954315bd4236fa72e7d8618306e1f9dc1128f0000000100000cd2
 class="parameter">username</replaceable></option></term>
       <listitem>
       <para>
       Connect to the database as the user <replaceable
       class="parameter">username</replaceable> instead of the default.
       </para>
       </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-V</option></term>
      <term><option>--version</option></term>
       <listitem>
        <para>
         Print the <application>pg_isready</application> version and exit.
        </para>
       </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-?</option></term>
      <term><option>--help</option></term>
      <listitem>
       <para>
        Show help about <application>pg_isready</application> command line
        arguments, and exit.
       </para>
      </listitem>
     </varlistentry>
   </variablelist>
 </refsect1>

 <refsect1>
  <title>Exit Status</title>

  <para>
   <application>pg_isready</application> returns <literal>0</literal> to the shell if the server
   is accepting connections normally, <literal>1</literal> if the server is rejecting
   connections (for example during startup), <literal>2</literal> if there was no response to the
   connection attempt, and <literal>3</literal> if no attempt was made (for example due to invalid
   parameters).
  </para>
 </refsect1>

 <refsect1>
  <title>Environment</title>

  <para>
   <command>pg_isready</command>, like most other <productname>PostgreSQL</productname>
   utilities,
   also uses the environment variables supported by <application>libpq</application>
   (see <xref linkend="libpq-envars"/>).
  </para>

  <para>
   The environment variable <envar>PG_COLOR</envar> specifies whether to use
   color in diagnostic messages. Possible values are
   <literal>always</literal>, <literal>auto</literal> and
   <literal>never</literal>.
  </para>
 </refsect1>

 <refsect1 id="app-pg-isready-notes">
  <title>Notes</title>

  <para>
   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.
  </para>
 </refsect1>

 <refsect1 id="app-pg-isready-examples">
  <title>Examples</title>

  <para>
   Standard Usage:
<screen>
<prompt>$</prompt> <userinput>pg_isready</userinput>
<computeroutput>/tmp:5432 - accepting connections</computeroutput>
<prompt>$</prompt> <userinput>echo $?</userinput>
<computeroutput>0</computeroutput>
</screen>
  </para>

  <para>
   Running with connection parameters to a <productname>PostgreSQL</productname> cluster in startup:
<screen>
<prompt>$ </prompt><userinput>pg_isready -h localhost -p 5433</userinput>
<computeroutput>localhost:5433 - rejecting connections</computeroutput>
<prompt>$</prompt> <userinput>echo $?</userinput>
<computeroutput>1</computeroutput>
</screen>
  </para>

  <para>
   Running with connection parameters to a non-responsive <productname>PostgreSQL</productname> cluster:
<screen>
<prompt>$ </prompt><userinput>pg_isready -h someremotehost</userinput>
<computeroutput>someremotehost:5432 - no response</computeroutput>
<prompt>$</prompt> <userinput>echo $?</userinput>
<computeroutput>2</computeroutput>
</screen>
  </para>

 </refsect1>

</refentry>

Title: pg_isready: Exit Status, Environment Variables, Notes, and Examples
Summary
This section details the exit statuses returned by `pg_isready`, indicating the server's connection status (accepting, rejecting, no response, or no attempt). It also describes the environment variables used by `pg_isready`, particularly those supported by `libpq` and `PG_COLOR`. Additionally, it notes that providing incorrect credentials will result in logged failed connection attempts. Finally, it provides usage examples, demonstrating standard usage and scenarios where the server is starting up or non-responsive.