start stop restart postgres postgresql & important remote access files ubuntu

— after installing postgresql on ubuntu linux – the two following commands are suggested by the installer
— the following to start the cluster

pg_ctlcluster 13 main start

— then this message along with the “systemctl” command to autostart

Warning: the cluster will not be running as a systemd service. Consider using systemctl:
sudo systemctl start postgresql@13-main
Error: You must run this program as the cluster owner (postgres) or root

— to manually Start stop and restart postgressql

sudo service postgresql restart
sudo service postgresql start
sudo service postgresql stop

— on the server you have postgres installed on
— to allow remote access, make sure your remote host is in the list or wildcard in this file

/etc/postgresql/13/main/postgresql.conf

— this line is commented out by default in postgresql.conf

listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)

— on ubuntu – to allow remote login

/etc/postgresql/13/main/pg_hba.conf

— add the following two lines to the end of file pg_hba.conf
— these entries are tab separated (hard to see that)

host all all 0.0.0.0/0 md5
host all all ::/0 md5

Leave a Comment

Scroll to Top