33

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 ?

  • is this a new pg install or did you just do an upgrade? check that the postgres user has rights to the pg config file and log file – LinuxDevOps Apr 7 '14 at 17:11
  • 3
    Try running postgres the same way as your script does (normally su - postgres; /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data and see what it gives you. You may need to change user name and paths depending on your setup. – Jenny D Apr 7 '14 at 17:25
  • In addition to what @JennyD said, I would add -d 3 to the postgres command. This will enable more extensive debugging output written to the log. You can lower the debugging output by changing it to 1 or 2, or increase it by changing it to 4 or 5. Also, what is the output of which pgsql? – zymhan Apr 7 '14 at 18:50
  • How was PostgreSQL installed on the server and from where? Is there anything in the system logs, e.g. /var/log/syslog, /var/log/messages, etc? – Craig Ringer Apr 8 '14 at 3:09
  • 6
    I don't understand why this question was closed. – guettli Nov 5 '15 at 10:22
52

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.

  • 1
    starting it manually works for me, but using service still doesnt. i changed the default data directory, is there something i would need to update to make the service command work again for starting postgres? – chrismarx Jul 1 '14 at 2:08
  • 1
    @chrismarx - The service command is just a convenient wrapper around the /etc/init.d/ script that actually starts and stops the process. You'll need to look at that script to see what it's doing differently from when you manually run it. Doing something like bash -x /etc/init.d/postgresql start might be a good place to start your research. – Christopher Cashell Jul 1 '14 at 23:28
  • 3
    thanks, i got this sorted, there were permissions issues with data directory, and seems like service also had to be run with sudo – chrismarx Jul 2 '14 at 0:57
  • 1
    Lifesaver. I couldn't find any other way to tell why PostgreSQL won't start, as it was because it couldn't access its data directory because of permission problems. – Aron Lorincz Oct 8 '15 at 7:08
  • 1
    for me it was permission of configs /etc/postgresql/ – eugene May 27 '18 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.