postgres server fails to start, produces no log, how to to troubleshoot?

I'm starting up a postgres 9.3 instance on a ubuntu 12.04 server :

~# service postgresql start 

 * The PostgreSQL server failed to start. Please check the log output.
                                                                     [fail]

the start fails, but it leaves no log, this file is empty :

tail /var/log/postgresql/postgresql-9.3-main.log 

and the are no other files in this directory : /var/log/postgresql/

what is the best way to troubleshoot this ?


Try running it manually with debug enabled. This will cause it to run in the foreground and print any error messages to standard error, while also increasing the verbosity.

I believe this will be the correct command line for PostgreSQL 9.3 on Ubuntu, but it might require some very slight tweaking (note: line is split for readability; you can recombine it to a single line (without the backslash) if you want):

/usr/lib/postgresql/9.3/bin/postgres -d 3 -D /var/lib/postgresql/9.3/main \
   -c config_file=/etc/postgresql/9.3/main/postgresql.conf

The beginning is the location of the postgres binary, then we enable debug and set it to level 3 (you can adjust this up or down to increase or decrease verbosity). Next we specify the data directory and the config file to start with. These should be the defaults for Ubuntu Server 12.04, I think.

Hopefully, that'll give you enough information to determine where the problem is.


Based on the answer of @christopher:

With postgres 12 on ubuntu, I ran:

# with my custom data dir:
/usr/lib/postgresql/12/bin/postgres -d 3 -D /media/ssd1/pg_data -c config_file=/etc/postgresql/12/main/postgresql.conf

# with default config:
/usr/lib/postgresql/12/bin/postgres -d 3 -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf

In my case, the issue was the following:

2020-06-02 15:27:45.468 GMT [2522] LOG:  skipping missing configuration file "/media/ssd1/pg_data/postgresql.auto.conf"
2020-06-02 17:27:45.469 CEST [2522] FATAL:  data directory "/media/ssd1/pg_data" has wrong ownership
2020-06-02 17:27:45.469 CEST [2522] HINT:  The server must be started by the user that owns the data directory.
2020-06-02 17:27:45.469 CEST [2522] DEBUG:  shmem_exit(1): 0 before_shmem_exit callbacks to make
2020-06-02 17:27:45.469 CEST [2522] DEBUG:  shmem_exit(1): 0 on_shmem_exit callbacks to make
2020-06-02 17:27:45.469 CEST [2522] DEBUG:  proc_exit(1): 0 callbacks to make
2020-06-02 17:27:45.469 CEST [2522] DEBUG:  exit(1)

I had no useful info in sudo cat /var/log/postgresql/postgresql-12-main.log And sudo systemctl start postgresql produced no output