'How to restart Postgresql

I have PostgreSQL 9.3 and 9.4 installed on my Linux Mint machine.

How can I restart PostgreSQL 9.4?

A method to restart both versions together is also fine.



Solution 1:[1]

You can also restart postgresql by using this command, should work on both the versions:

sudo service postgresql restart

Solution 2:[2]

On Windows :

1-Open Run Window by Winkey + R

2-Type services.msc

3-Search Postgres service based on version installed.

4-Click stop, start or restart the service option.

On Linux :

sudo systemctl restart postgresql

also instead of "restart" you can replace : stop or status.

Solution 3:[3]

This should work:

sudo systemctl stop postgresql

sudo systemctl start postgresql

Solution 4:[4]

The right way to restart postgres server is to use

pg_ctl restart -D /home/postgres/postgresdbdata/

pg_ctl is usually found in location usr/local/pgsql/bin/pg_ctl if u dont have it added to your path.

Documentation can be found here https://www.postgresql.org/docs/13/app-pg-ctl.html This has more details on Start,Stop,Restart,etc of the postgres server.

Solution 5:[5]

You can firstly check for the postgress process running

ps -ef | grep post

You might need to use (post|pg) on the grep side, to discover the process for the Postgres service running on your machine, it might depend on your OS.

And you can just kill the child process since most of this process should restart automatically.

sudo kill $pid_of_the_child_process

Solution 6:[6]

macOS:

  1. On the top left of the MacOS menu bar you have the Postgres Icon
  2. Click on it this opens a drop down menu
  3. Click on Stop -> than click on start

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Zeitler
Solution 2
Solution 3 Yankee
Solution 4 Jenison Gracious
Solution 5 Aecio Levy
Solution 6