I previously installed PostgreSQL by following this documentation then I uninstalled it using the following commands (I'm on Fedora)
sudo rm -rf /var/lib/pgsql/
sudo dnf remove postgresql postgresql-server
After that I tried to reinstall it again but changing the default port from 5432
to 5433
:
sudo dnf install postgresql postgresql-server
sudo postgresql-setup --initdb --unit postgresql --port 5433
The /var/lib/pgsql/data/postgresql.conf
file does indeed have the line port = 5433
uncommented
But when I try to start the service using sudo systemctl start postgresql
, I get the following error
Job for postgresql.service failed because the control process exited with error code.
See "systemctl status postgresql.service" and "journalctl -xeu postgresql.service" for details.
Here are the logs from the log
folder:
2023-05-04 10:46:56.034 CEST [6340] LOG: starting PostgreSQL 15.1 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 13.0.1 20230117 (Red Hat 13.0.1-0), 64-bit
2023-05-04 10:46:56.034 CEST [6340] LOG: could not bind IPv6 address "::1": Permission denied
2023-05-04 10:46:56.034 CEST [6340] LOG: could not bind IPv4 address "127.0.0.1": Permission denied
2023-05-04 10:46:56.034 CEST [6340] WARNING: could not create listen socket for "localhost"
2023-05-04 10:46:56.034 CEST [6340] FATAL: could not create any TCP/IP sockets
2023-05-04 10:46:56.036 CEST [6340] LOG: database system is shut down
However when I start PostgreSQL without using postmaster
it works
sudo su - postgres
/usr/bin/postmaster -D /var/lib/pgsql/data
Here are the logs:
2023-05-04 11:08:18.997 CEST [9385] LOG: starting PostgreSQL 15.1 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 13.0.1 20230117 (Red Hat 13.0.1-0), 64-bit
2023-05-04 11:08:18.998 CEST [9385] LOG: listening on IPv6 address "::1", port 5433
2023-05-04 11:08:18.998 CEST [9385] LOG: listening on IPv4 address "127.0.0.1", port 5433
2023-05-04 11:08:19.000 CEST [9385] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
2023-05-04 11:08:19.002 CEST [9385] LOG: listening on Unix socket "/tmp/.s.PGSQL.5433"
2023-05-04 11:08:19.009 CEST [9389] LOG: database system was shut down at 2023-05-04 10:46:43 CEST
2023-05-04 11:08:19.030 CEST [9385] LOG: database system is ready to accept connections
In /usr/lib/systemd/system
I have two services related to PostgreSQL
-rw-r--r--. 1 root root 1546 20 janv. 01:00 postgresql.service
-rw-r--r--. 1 root root 1507 20 janv. 01:00 postgresql@.service
I checked to content and nothing seems weird to me.
In the postgresql.conf
file if I change the port to 5432
then it works, I can successfully start the service!
I checked if there's anything already using the port 5433
with the command netstat -aon | grep 5433
but it seems not
Any idea what could cause this problem when changing the default port? I'm kind of new to Linux and I'm unfamiliar with services.
Thanks for your answers
systemd
service file. Does this help you ?Have a look at this command
ExecStart=/usr/local/pgsql/bin/pg_ctl -o "-p 5489"
– ramius May 04 '23 at 10:26