You may receive this error when there are multiple IPs on the same server that use the same port. In this case, you cannot run the postgresql service. You may encounter an error like the following when you try to start PostgreSQL Service.
Start PostgreSQL
1 2 | [root@test01 system]# systemctl start postgresql-11.service Job for postgresql-11.service failed because the control process exited with error code. See "systemctl status postgresql-11.service" and "journalctl -xe" for details. |
Check PostgreSQL Status
We will also see these errors when we check the status of the PostgreSQL service with the following script.
1 2 3 4 5 6 7 8 9 10 | [root@test01 system]# systemctl status postgresql-11.service Oct 24 15:01:22 test01.mycompany.lokal systemd[1]: Starting PostgreSQL 11 database server... Oct 24 15:01:23 test01.mycompany.lokal postmaster[97373]: 2019-10-24 15:01:23.014 +03 [97373] LOG: listening on IPv6 address "::1", port 5432 Oct 24 15:01:23 test01.mycompany.lokal postmaster[97373]: 2019-10-24 15:01:23.014 +03 [97373] LOG: listening on IPv4 address "127.0.0.1", port 5432 Oct 24 15:01:23 test01.mycompany.lokal postmaster[97373]: 2019-10-24 15:01:23.014 +03 [97373] FATAL: lock file "/var/run/postgresql/.s.PGSQL.5432.lock" already exists Oct 24 15:01:23 test01.mycompany.lokal postmaster[97373]: 2019-10-24 15:01:23.014 +03 [97373] HINT: Is another postmaster (PID 38016) using socket file "/var/run/postgresq...SQL.5432"? Oct 24 15:01:23 test01.mycompany.lokal systemd[1]: postgresql-11.service: main process exited, code=exited, status=1/FAILURE Oct 24 15:01:23 test01.mycompany.lokal systemd[1]: Failed to start PostgreSQL 11 database server. Oct 24 15:01:23 test01.mycompany.lokal systemd[1]: Unit postgresql-11.service entered failed state. Oct 24 15:01:23 test01.mycompany.lokal systemd[1]: postgresql-11.service failed. |
Solution
When we delete locks in the following way, we can start postgresql without receiving these errors.
1 | rm /var/run/postgresql/.s.PGSQL.5432.lock |
Note: You must have set the IP from postgresql.conf.