If you have Ubuntu 16.04 use next command to restart Postgres:
sudo service postgresql restart
If you have Ubuntu 18.04 use next command to restart Postgres:
sudo systemctl restart postgresql.service
If you want to know the status of Postgres uses the next command:
systemctl status postgresql.service
You have to see something like this: