0

I have been living in hell for 2 days now. I've tried everything. Originally, I was getting an error that involved some kind of postmaster.pid file, that didn't exist. It looked like something caused the server to stop unexpectedly which caused all sorts of problems. Then I was having issues logging in, and no matter what I did, I kept getting a wrong password error. Just for doing psql it was asking for password. I don't remember needing to do that & I'd prefer to not need a password for that.

I have tried restarting my computer and completely uninstalling ALL postgres files and apps and everything, and redownloading it all, and I still get error after error. I just want the server to start and I want the psql command to work in the terminal (MacOS btw).

This is the latest error I'm getting. The server won't start and tells me to look at the logs.

This is the logs:

2021-12-24 17:50:46.439 PST [1242] LOG:  starting PostgreSQL 14.1 on xxxx, compiled by Apple clang version 12.0.5 (xxxx), 64-bit
2021-12-24 17:50:46.444 PST [1242] LOG:  listening on IPv6 address "xxxx", port 5432
2021-12-24 17:50:46.444 PST [1242] LOG:  listening on IPv4 address "xxxxx", port 5432
2021-12-24 17:50:46.446 PST [1242] FATAL:  could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
2021-12-24 17:50:46.448 PST [1242] LOG:  database system is shut down

What do I do? Please, I will try anything!

Edit: I found something online that says to remove the lock file. How do I do that? Is it as simple as rm /tmp/.s.PGSQL.5432.lock ? After I did that, I got a message saying override rw------- 503/wheel for /tmp/.s.PGSQL.5432.lock? what do I do to answer that?

5
  • You should provide some info about /tmp dir, such as ls -al /tmp Commented Dec 25, 2021 at 3:23
  • @axlis After that command I get lrwxr-xr-x@ 1 root wheel 11 Jan 1 2020 /tmp -> private/tmp Can you please help me from here? I have no idea what I'm doing. Commented Dec 25, 2021 at 5:35
  • Check if the instructions in this post works: stackoverflow.com/questions/22851352/… Commented Dec 25, 2021 at 5:43
  • @rajorshi Hi, thanks for your reply. I tried the first solution. The first command they said to do is this: sudo chown -R postgres:postgres /var/run/postgresql and I get the following chown: postgres: illegal group name What do I do now? Commented Dec 25, 2021 at 7:21
  • The lock is owned by a user 503, so the postgres user seems to have a new id (if any) and the postgres group no longer exists. You need to install postgresql correctly. Commented Dec 26, 2021 at 1:46

1 Answer 1

3

First I reproduce the problem in my system(centos 8)

systemctl start postgresql.service # Normal.

su --command psql postgres # Get the shell successfully.

chown root:root /tmp/.s.PGSQL.5432.lock # Something bad!

systemctl restart postgresql.service # Fail.

Service Log

Stopped PostgreSQL database server.
Starting PostgreSQL database server...
could not open lock file "/tmp/.s.PGSQL.5432.lock": Permission denied
database system is shut down

Then you should understand the problem

rm -f /tmp/.s.PGSQL.5432.lock # Fix the problem in my system.

systemctl restart postgresql.service

su --command psql postgres # Get the shell successfully again.

Here is the correct permission may help you solve the problem

drwxrwxrwt.   3 root root  4096 Dec 25 19:39 tmp

srwxrwxrwx   1 postgres postgres    0 Dec 25 19:36 .s.PGSQL.5432
-rw-------   1 postgres postgres   48 Dec 25 19:36 .s.PGSQL.5432.lock

My personal suggestion

Understand the meaning the error message is the key to solve it.

3
  • Thanks @axlis, I removed the lock file and then also ran the restart command. Then psql still does not work for me. Now I check the logs and see the error "could not bind Unix address /tmp/.s.PGSQL.5432": Address already in use What do I do now? I have no idea what is in that address... Commented Dec 26, 2021 at 0:50
  • You should remove the .s.PGSQL.5432 also, it is just a socket. The service will recreate it when restart. Commented Dec 26, 2021 at 2:14
  • thank you. I did that, and then I also had to createdb for my name. Now I got psql to work! The Postgres app says port in use but I think that might be because I started the port with homebrew? Commented Dec 26, 2021 at 4:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.