0

I try to uncomment 'unix_socket_directories = '/var/run/postgresql' in postgresql.conf.

But after doing that, when I try to restart postgresql, I receive

  Job for postgresql.service failed because the control process exited with error code. See 
  "systemctl status postgresql.service" and "journalctl -xe" for details.

Looking for journalctl, I see:

LOG:  could not bind Unix socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not, remove socket file 
"/var/run/postgresql/.s.PGSQL...and retry.
: WARNING:  could not create Unix-domain socket in directory "/var/run/postgresql"

Full stack:

 Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; 
 vendor preset: disabled)
  Active: failed (Result: exit-code) since Ср 2020-01-29 13:39:52 MSK; 
 27s ago
  Process: 2937 ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast 
 (code=exited, status=1/FAILURE)
  Process: 2550 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p 
 ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS)
  Process: 2544 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} 
 (code=exited, status=0/SUCCESS)
 Main PID: 2554 (code=killed, signal=KILL)

   plesk.iline.pro systemd[1]: Starting PostgreSQL database server...
   plesk.iline.pro pg_ctl[2550]: LOG:  could not bind Unix socket: 
   Address already in use
   plesk.iline.pro pg_ctl[2550]: HINT:  Is another postmaster already 
   running on port 5432? If not, remove socket file 
   "/var/run/postgresql/.s.PGSQL...and retry.
    plesk.iline.pro pg_ctl[2550]: WARNING:  could not create Unix- 
    domain socket in directory "/var/run/postgresql"
    plesk.iline.pro systemd[1]: Started PostgreSQL database server.
    2 plesk.iline.pro systemd[1]: postgresql.service: main process 
    exited, code=killed, status=9/KILL
    plesk.iline.pro pg_ctl[2937]: pg_ctl: could not send stop signal 
    (PID: 2554): No such process
    plesk.iline.pro systemd[1]: postgresql.service: control process 
    exited, code=exited status=1
    plesk.iline.pro systemd[1]: Unit postgresql.service entered failed 
    state.
    plesk.iline.pro systemd[1]: postgresql.service failed.
    Hint: Some lines were ellipsized, use -l to show in full.
2
  • Which PostgreSQL version is that? Commented Jan 29, 2020 at 11:27
  • version PostgreSQL is 9.2 Commented Jan 29, 2020 at 11:37

1 Answer 1

2

Likely there is another PostgreSQL server running on the same port.

You should do what PostgreSQL recommends:

ls -l /var/run/postgresql/.s.PGSQL.5432

There should be a socket file present.

Then, as user root, see if there is a PostgreSQL process listening on the port:

sudo fuser /var/run/postgresql/.s.PGSQL.5432

If there is a result, there is really another PostgreSQL server running on port 5432. Either stop that server or choose a different port for your cluster.

If there is no result, the socket may be left over. Remove it and try again.

Sign up to request clarification or add additional context in comments.

8 Comments

I have no result after running this commands. And how can I remove socket. I have tried 'rm .s.PGSQL.5432', but receive 'failed to remove .s.PGSQL.5432 as its a directory
What does "no result" mean? An error "no such file or directory"? Something else? Details, please.
After ls -l /var/run/postgresql/.s.PGSQL.5432 next line retrieve 0.
"retrieve 0" doesn't make much sense to me. Kill all PostgreSQL processes on the machine, remove /var/run/postgresql/.s.PGSQL.5432 and try again.
There is a command called rm for that: sudo rm -f /var/run/postgresql/.s.PGSQL.5432
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.