How to restart PostgreSQL in Ubuntu 18.04

sudo service postgresql restart

systemctl restart postgresql@<postgres_version>-<cluster_name>.service

By default cluster_name = 'main', run this command to list all the clusters you have :

ls /var/lib/postgresql/

if you want to know whether the postgresql is running try this command :

systemctl status postgresql@<postgres_version>-<cluster_version>.service

My postgresql service is named postgresql-9.5; in case you get "postgresql: unrecognized service" you can find its name with

sudo service --status-all | grep postgresql

and then proceed as per the accepted answer.

Tags:

Postgresql