How to start stop PostgreSQL server using pg_ctl

In this article, we will see how to start stop PostgreSQL server using pg_ctl.

We can start or stop or promote PostgreSQL server(cluster) by using following three methods.

1. Using pg_ctl
2. Using Systemctl
3. Using service

Last two methods are straight forward.

How to start stop restart PostgreSQL server using pg_ctl

pg_ctl is the utility used to start stop status or promote/failover of PostgreSQL cluster(server).
To use pg_ctl to start the PostgreSQL, we must have an already existing or newly initialized data directory.
We have to use PostgreSQL server data directory location while using pg_ctl.

Before going to examples, set the PostgreSQL environment variables using this link

Syntax of pg_ctl: Continue reading How to start stop PostgreSQL server using pg_ctl

How to find the PostgreSQL server uptime

In this article, we will see how to find the PostgreSQL server uptime. To find the PstgreSQL server uptime, we use PostgreSQL built-in function pg_postmaster_start_time(). Or by checking the time host and postgresql server start time.

Find the PostgreSQL server uptime

Continue reading How to find the PostgreSQL server uptime

psql: could not connect to server: Connection refused

In this article, we will the solution for below error.

psql: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

psql could not connect to server Connection refused
Continue reading psql: could not connect to server: Connection refused

psql: FATAL: the database system is starting up

In this article, we will the solution for below error.

psql: FATAL: the database system is starting up

psql FATAL the database system is starting up

Continue reading psql: FATAL: the database system is starting up

How to check PostgreSQL is running or not

In this article, we will see how to check PostgreSQL is running or not on Linux and Windows.

Following commands are used to check the status of PostgreSQL is running or not on Linux Operating Systems. There are several ways to find out
Continue reading How to check PostgreSQL is running or not