A freshly installed PostgreSQL (with configuration overwritten) won't start:

$ sudo service postgresql start
 * Starting PostgreSQL 9.1 database server
 * Error: could not read /etc/postgresql/9.1/main/postgresql.conf: Permission denied

Looks like it should be able to read it though:

$ ls -l postgresql.conf 
-rw------- 1 postgres postgres 19450 2012-06-14 10:07 postgresql.conf

But fine, I'll add chmod +r it to test if that works.

$ sudo chmod +r postgresql.conf 
$ sudo service postgresql start
 * Starting PostgreSQL 9.1 database server
 * The PostgreSQL server failed to start. Please check the log output:
Error: Could not open log file /var/log/postgresql/postgresql-9.1-main.log


$ ls -l /var/log/postgresql/
total 4
-rw-r----- 1 postgres adm 827 2012-06-14 10:07 postgresql-9.1-main.log

I don't get it. What can be wrong here? This used to work before.

Can I maybe monitor what process attempts to open the file?

It's Ubuntu 11.10 on EC2, using Chef. For completeness, here's the recipe:

# Install PostgreSQL
package "postgresql-9.1"

# Stop server
service "postgresql" do
    action :stop

# Overwrite configuration (setting data dir)
template "/etc/postgresql/9.1/main/postgresql.conf" do
    source "postgresql-conf.erb"
    owner "postgres"
    group "postgres"

# Start server
service "postgresql" do
    action :start
  • 1
    First, please do not go randomly shotgunning permissions - that's NOT how you fix something, it's how you create an even bigger mess. Instead, proceed logically with troubleshooting: Postgres can not read/write log files it used to (and should) have access to. Why? Possible reasons: (1) Is the server tryng to start/run as the postgres user? (Check the startup scripts) ; Are there multiple users named postgres with different UIDs? (check /etc/passwd) ; etc… – voretaq7 Jun 14 '12 at 14:48
  • @voretaq7 I know, that was just a quick fix to try to get it to work. Once it works, I have time to figure out why exactly it doesn't work. – Bart van Heukelom Jun 14 '12 at 15:34

The custom configuration file (postgresql.conf) pointed to a data directory that did not exist. Of course, that's a problem (which I solved by setting up the data directory), but it has nothing to do with the error printed. Once again, PostgreSQL errors not so helpful.


I got the same error when the data directory existed, but with incorrect ownership.

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.