Back to commands

Hosting Operations

Read-only

Check Whether PostgreSQL Is Accepting Connections

An app cannot reach PostgreSQL and you need a quick first-response check before digging into logs or credentials.

Command

pg_isready -h 127.0.0.1 -p 5432

Before you run this

System impact: Read-only. Low when scoped to the shown target.

When not to use it: Do not treat readiness as proof that a specific user, database, or query works.

Expected output

A line showing host, port, and whether PostgreSQL is accepting connections.

System impact

Read-only. Nothing changes. pg_isready reports whether the server accepts connections.

Recovery / rollback: no state is changed.

When to use it

Use during deploys, incident triage, service restarts, and health checks.

When not to use it

Do not treat readiness as proof that a specific user, database, or query works.

next steps

Related commands

Hosting Operations Read-only

Check Whether MySQL Responds

The port was open. MySQL still had to answer.

mysqladmin ping -h 127.0.0.1 -P 3306
Hosting Operations Sensitive output

Show Active MySQL Sessions

The app was waiting behind busy sessions.

mysql -e "show full processlist;"
Hosting Operations Read-only

Check PostgreSQL Lock Waits

The outage was a queue, not a crash.

psql -X -c "select pid, wait_event_type, wait_event, state, left(query, 80) as query from pg_stat_activity where wait_event_type is not null order by pid;"
Hosting Operations Read-only

Show Active PostgreSQL Connections

The database was not down. It was full.

psql -X -A -F '|' -c "select pid,usename,datname,state,client_addr from pg_stat_activity order by state, pid;"
Hosting Operations Read-only

Find Long-Running PostgreSQL Queries

One query can make the whole app look broken.

psql -X -c "select pid, now() - query_start as age, state, left(query, 80) as query from pg_stat_activity where query_start is not null order by age desc limit 10;"
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • LFCS style performance-task practice

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.