Reputation: 1296
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.
Upvotes: 0
Views: 5058
Reputation: 246013
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.
Upvotes: 2