How to Check the Status of PostgreSQL on an Ubuntu Server

How to Check PostgreSQL Status on Ubuntu

PostgreSQL, often referred to as Postgres, is a powerful open-source relational database system. It’s widely used by developers and administrators for its advanced features and performance. When running PostgreSQL on an Ubuntu server, it’s essential to know how to check its status to ensure its smooth operation.

Whether you’re using a dedicated server, a virtual server, cloud hosting, or even shared hosting, understanding the status of your PostgreSQL instance is crucial.

In this guide, we’ll walk you through the steps to check the status of PostgreSQL on Ubuntu.

Let’s get started.

Step 1: Access the Terminal

Before you can check the status of PostgreSQL, you need to access the terminal. If you’re working directly on the Ubuntu server, open the terminal application. If you’re accessing the server remotely, use an SSH client.

Step 2: Use the systemctl Command

Ubuntu uses the systemd system manager, and the systemctl command is a primary tool to interact with it. To check the status of PostgreSQL:

sudo systemctl status postgresql

This command will display the current status of the PostgreSQL service, whether it’s active, inactive, or failed. It will also show recent logs related to the service.

See also  How to Download Ubuntu Server 11.10 ISO

Step 3: Interpret the Output

When you run the above command, you’ll see an output similar to:

postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since [timestamp]
  Process: [PID] ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: [PID] (code=exited, status=0/SUCCESS)

The key line to note is the “Active” line. If PostgreSQL is running, it will say “active”. If it’s not running, it might say “inactive” or “failed”.

Step 4: Check the Status of Specific PostgreSQL Clusters

PostgreSQL supports running multiple clusters on a single machine. To check the status of specific clusters:


This command will display the version, cluster name, port, status, owner, data directory, and log file for each cluster.

See also  How to Uninstall aaPanel on Ubuntu

Commands Mentioned

  • sudo systemctl status postgresql – Checks the status of the PostgreSQL service.
  • pg_lsclusters – Lists all PostgreSQL clusters and their statuses.


  1. How do I start PostgreSQL if it’s not running?

    You can start PostgreSQL using the command: `sudo systemctl start postgresql`.

  2. How can I enable PostgreSQL to start on boot?

    Use the command: `sudo systemctl enable postgresql` to ensure PostgreSQL starts on boot.

  3. What if I encounter an error while checking the status?

    Errors might be due to insufficient permissions or PostgreSQL not being installed. Ensure you have the right permissions and that PostgreSQL is installed on your server.

  4. Can I check the status of PostgreSQL without sudo?

    While `systemctl` requires sudo for many operations, `pg_lsclusters` can typically be run without sudo to check the status of individual clusters.

  5. How do I stop PostgreSQL?

    You can stop PostgreSQL using the command: `sudo systemctl stop postgresql`.

See also  How to Uninstall Piwik/Matomo Analytics on Ubuntu


Checking the status of PostgreSQL on Ubuntu is a straightforward process, thanks to the systemctl and pg_lsclusters commands. Regularly monitoring the status of your PostgreSQL instance ensures that your database operations run smoothly. Whether you’re on a dedicated server, a VPS, or any other hosting environment, understanding the health and status of your PostgreSQL service is crucial for optimal performance and uptime. Always ensure you have backups and follow best practices when making changes to your database system.


Leave a Reply

Your email address will not be published. Required fields are marked *