PostgreSQL is one of the most used RDBMS that is compatible with all the major operating systems, like Windows, Linux, and MacOS. Installing PostgreSQL on Windows allows us to store, manipulate, and retrieve enormous data efficiently. While working with Postgres, you may come across a situation where you need to restart the Postgres server. The possible reasons might be an inactive/dead server, system crashes, lags, etc. In such situations restarting the Postgres server can be proved very fortunate.
This post will present a step-by-step guide on restarting the PostgreSQL server on the Windows operating system.
How to Restart PostgreSQL Server on Windows
There are various methods to restart a Postgres Server on Windows. In this write-up, the following methods will be discussed to restart the Postgres server:
- Method 1: Using GUI (Services Manager).
- Method 2: Using CLI (Command Prompt).
Method 1: Restart Postgres Server Using GUI
Press the “Win + S” button to open the windows search bar, type “services”, and hit the “Open” button to launch the services Window:
Once the “Services Manager” is opened, discover the “Postgresql-x64-15”, select the stated service, and press the “restart” button to restart the Postgres server:
Once you click on the “Restart” button the Postgres Server will be re-initiated.
Method 2: Restart Postgres Server Using CMD
Type “CMD” in the windows search bar, and click on the “Open” button to launch the Windows command prompt:
Once the CMD is opened, type the following “pg_ctl” command to re-initiate the Postgres Server:
pg_ctl -D "C:\Program Files\PostgreSQL\15\data" restart
The output snippet clearly states that the server has been restarted successfully.
Conclusion
In PostgreSQL, the “pg_ctl” command and “services manager” can be used to restart the Postgres server on the Windows operating system. The Postgres users may come across a situation where they need to restart the Postgres server, such as having an inactive/dead server, system crashes, lags, etc. In such situations restarting the Postgres server can be proved very fortunate. This article has presented a step-by-step guide on how to restart the Postgres server on the Windows operating system.