Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently had to replace my postgresql.conf file, and I thought I got the settings right, but when I try to run Postgresql, I get this error:

 ESTFATAL:  could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory

My workaround is to go as root and create a folder called postgresql in /var/run and then change the owner of the folder to postgres.

The biggest problem is that I need to do this every single time my computer starts, the folder somehow deletes itself.

I tried commenting out the external pid file bit in the conf file, but that didn't change anything.

share|improve this question
Which distro are you running? Post the init script /etc/init.d/postgresql? – quanta Nov 14 '11 at 16:01
I am running Ubuntu, the init script is the one that comes with postgresql, Postgresql used to run on startup, but now it doesn't. I am guessing that the script encounters the same error as above. Where can I go and check startup errors? – zermy Nov 14 '11 at 18:03
  • What version of postgresql are you running?
  • What repo is it from?
  • Can you post your config file and init script?

I tried commenting out the external pid file bit in the conf file, but that didn't change anything.

Try having it write the pid file out to /var/run/FILE instead of /var/run/postgresql/FILE.

[Edit 1]:

The default socket directories for apps are usually /tmp as it's world writable (which var isn't, of course creating the directory and setting permissions allows this to work, it's rather non-standard and might be better using the standard settings). Also, I'd leave the extra pid line commented out since the init script doesn't use it.

share|improve this answer
I am running PG 9.1. I seem to have fixed it for the time being. In the conf file, I changed the location of the socket and the pid file from /var/run/postgresql to /var/postgresql. I made the directory postgresql, and set it's owner to postgres. But, if you are still curious, here is the config file and here is the init.d script. – zermy Nov 15 '11 at 15:23
See [Edit 1] above. – Andrew Case Nov 15 '11 at 17:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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