Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to start Postgres Server because of permission denied on lock file

Tags:

postgresql

I restarted my Postgres server but now. I checked my "pgstartup.log" log file. This says:

creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:
/usr/bin/postgres -D /var/lib/pgsql/data
/usr/bin/pg_ctl -D /var/lib/pgsql/data -l logfile start

FATAL:  could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
FATAL:  could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied

Do you think deleting /tmp/.s.PGSQL.5432.lock would work ?

like image 682
Sarthak Saxena Avatar asked Nov 26 '15 16:11

Sarthak Saxena


2 Answers

If you know that no other Postgres processes are running, please delete these 2 files and try again:

$ sudo rm /tmp/.s.PGSQL.5432.lock
$ sudo rm /tmp/.s.PGSQL.5432

Then, you would be able to run the server as a background process with the command:

$ pg_ctl -D /usr/local/var/postgres start

If you are in OS X, put the alias in the.bash_profile as below:

alias pgb='pg_ctl -D /usr/local/var/postgres start'

Now, source it with the command:

$ source ~/.bash_profile

The Postgres server will run with the command:

$ pgb
like image 158
Heisenberg Avatar answered Oct 13 '22 17:10

Heisenberg


Postgres cannot write a file to /tmp because of permissions set on /tmp directory. As root user execute in terminal:

chmod 1777 /tmp
like image 21
Luca Perico Avatar answered Oct 13 '22 17:10

Luca Perico