Shared server guidance · Question & answer

Does pg_isready prove that my PostgreSQL login works?

pg_isready checks whether a PostgreSQL endpoint is responding and accepting connections. It does not prove that the supplied password, database or application permissions are valid. Use a second authenticated query to verify the application’s actual access path.

BeginnerLinux servers with PostgreSQL client utilities
Go to the answer

Before you start

  • The actual database endpoint and approved application account.

Instructions

1. Check readiness with a bounded timeout

Use the correct host and port. Supplying the intended user and database reduces irrelevant failed-login log entries, but correct credentials are not required for the readiness status itself.

Remote Linux shell
pg_isready -h 127.0.0.1 -p 5432 -U appuser -d appdb -t 5

Reports whether the endpoint is accepting, rejecting or not responding to PostgreSQL connection attempts.

2. Interpret readiness separately

The utility returns 0 for accepting, 1 for rejecting, 2 for no response and 3 when it could not make a valid attempt. These states describe the endpoint, not successful application authentication.

3. Perform an authenticated query

Use the actual application account and a password prompt. The constant SELECT tests query execution without reading customer tables; it does not test every application privilege.

Remote Linux shell
psql -X -h 127.0.0.1 -p 5432 -U appuser -d appdb -W -v ON_ERROR_STOP=1 -c 'SELECT 1;'

Connects as the chosen user and fails the command if the SQL test errors.

Check the result

  • Readiness reports accepting and the authenticated query completes successfully.
  • A representative authorised application operation is verified separately when permissions are part of the incident.

Troubleshooting

pg_isready succeeds but psql is denied
Investigate the account, password, database and matching authentication rule. Restarting a responsive database will not repair an incorrect credential.

Official references

Use the documentation for your installed version when a flag, service name or platform feature differs.