Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart PostgreSQL without postgresql-server

I'm on CentOS 7 and I'm trying to get through the 'PG::ConnectionBad: FATAL: Peer authentication failed for user' error.

So I've already figured out that I should change pg_hba.conf (peer to md5) and I've done it. It seems that I have to restart postgres but it is not so easy as I thought.

I tried 'service postgresql restart' which resulted in 'Failed to restart postgresql.service: Unit not found.'

Then tried to install posgresql-server. Got:

oct 23 01:16:15 serverct1 pg_ctl[3280]: HINT:  Is another postmaster already running on port 5432? If ...try.
oct 23 01:16:15 serverct1 pg_ctl[3280]: WARNING:  could not create listen socket for "localhost"
oct 23 01:16:15 serverct1 pg_ctl[3280]: FATAL:  could not create any TCP/IP sockets
oct 23 01:16:16 serverct1 pg_ctl[3280]: pg_ctl: could not start server
oct 23 01:16:16 serverct1 systemd[1]: postgresql.service: control process exited, code=exited status=1
oct 23 01:16:16 serverct1 systemd[1]: Failed to start PostgreSQL database server.

About 5432 port usage:

postgres        5432/tcp        postgresql      # POSTGRES
postgres        5432/udp        postgresql      # POSTGRES

So I'm curious:

1) Do postgresql and postgresql-server work separately?

2) Is it possible to restart posgresql without postgresql-server?

3) If not - how to get the port 5432 free in order to run postgresql-server?

like image 987
Alexander Gorg Avatar asked Dec 31 '25 10:12

Alexander Gorg


1 Answers

You can avoid troubles with serverct1 if you use standard postgres pg_ctl, eg:

pg_ctl reload

Or if needed pg_ctl reload -D $PGDATA

You dont need to restart the postgres for pg_hba changes to apply: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html

The pg_hba.conf file is read on start-up and when the main server process receives a SIGHUP signal. If you edit the file on an active system, you will need to signal the postmaster (using pg_ctl reload or kill -HUP) to make it re-read the file.

like image 123
Vao Tsun Avatar answered Jan 03 '26 23:01

Vao Tsun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!