After upgrade 14.04 to 16.04.1 Postgresql server does not start

Systemd should use script from /etc/init.d. Instead, systemd uses some kind of template file. To fix that, follow that steps:

  1. Remove invalid service script:

    # rm /lib/systemd/system/postgresql.service

  2. Reload daemon scripts:

    # systemctl daemon-reload

  3. Enable postgresql service:

    # systemctl enable postgresql

After that, you would be able to start postgres with any preferred variants: sudo systemctl start postgresql, sudo service postgresql start, or sudo /etc/init.d/postgresql start. To check that postgresql actually run, please check the status of service: sudo systemctl status postgresql. It sould looks like:

% sudo systemctl status postgresql                                                                                                                                                                          
● postgresql.service - LSB: PostgreSQL RDBMS server
   Loaded: loaded (/etc/init.d/postgresql; bad; vendor preset: enabled)
   Active: active (running) since Пт 2016-08-12 10:13:43 MSK; 1h 37min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/postgresql.service
           ├─4086 /usr/lib/postgresql/9.5/bin/postgres -D     /var/lib/postgresql/9.5/main -c  config_file=/etc/postgresql/9.5/main/postgresql.conf
           ├─4099 postgres: checkpointer process                                                                                              
           ├─4100 postgres: writer process                                                                                                    
           ├─4101 postgres: wal writer process                                                                                                
           ├─4102 postgres: autovacuum launcher process                                                                                       
           └─4103 postgres: stats collector process                                                                                           

авг 12 10:13:40 ubuntu-precise systemd[1]: Starting LSB: PostgreSQL RDBMS server...
авг 12 10:13:40 ubuntu-precise postgresql[4009]:  * Starting PostgreSQL 9.5 database server
авг 12 10:13:43 ubuntu-precise postgresql[4009]:    ...done.
авг 12 10:13:43 ubuntu-precise systemd[1]: Started LSB: PostgreSQL RDBMS server.

This should work out of the box if you provide the correct version and cluster name.

Lets say you're running version 9.5 and the cluster is called main:

Start: systemctl start [email protected]

Stop: systemctl stop [email protected]

Status: systemctl status [email protected]

Enable autostart on boot: systemctl enable [email protected]

Disable autostart on boot: systemctl disable [email protected]

foo@postgres:~$ systemctl status [email protected][email protected] - PostgreSQL Cluster 9.5-main
   Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-03-31 17:44:46 CEST; 59s ago
   Main PID: 4546 (postgres)
   CGroup: /system.slice/system-postgresql.slice/[email protected]
           ├ ─ 4546 /usr/lib/postgresql/9.5/bin/postgres -D /var/lib/postgresql/9.5/main -c config_file=/etc/postgresql/9.5/main/postgresql.conf
           ├ ─ 4548 postgres: checkpointer process
           ├ ─ 4549 postgres: writer process
           ├ ─ 4550 postgres: wal writer process
           ├ ─ 4551 postgres: autovacuum launcher process
           └ ─ 4552 postgres: stats collector process

Mar 31 17:44:44 postgres postgres[4546]: [1-2] 2017-03-31 17:44:44 CEST [4546] @ HINT:  Future log output will go to log destination "syslog".
Mar 31 17:44:44 postgres postgres[4547]: [2-1] 2017-03-31 17:44:44 CEST [4547] @ LOG:  database system was shut down at 2017-03-31 17:44:43 CEST
Mar 31 17:44:44 postgres postgres[4547]: [3-1] 2017-03-31 17:44:44 CEST [4547] @ LOG:  MultiXact member wraparound protections are now enabled
Mar 31 17:44:44 postgres postgres[4546]: [2-1] 2017-03-31 17:44:44 CEST [4546] @ LOG:  database system is ready to accept connections
Mar 31 17:44:44 postgres postgres[4551]: [2-1] 2017-03-31 17:44:44 CEST [4551] @ LOG:  autovacuum launcher started
Mar 31 17:44:45 postgres postgres[4553]: [3-1] 2017-03-31 17:44:45 CEST [4553] [unknown]@[unknown] LOG:  incomplete startup packet
Mar 31 17:44:46 postgres systemd[1]: Started PostgreSQL Cluster 9.5-main.
Mar 31 17:44:47 postgres systemd[1]: Reloading PostgreSQL Cluster 9.5-main.
Mar 31 17:44:47 postgres postgres[4546]: [3-1] 2017-03-31 17:44:47 CEST [4546] @ LOG:  received SIGHUP, reloading configuration files
Mar 31 17:44:47 systemd[1]: Reloaded PostgreSQL Cluster 9.5-main.