0

I have a problem similar to https://dba.stackexchange.com/questions/185622/how-do-i-change-postgresql-to-be-listening-on-port-5432 , though not necessarily exactly the same.

If port is defined as 5432 in /etc/postgresql/14/main/postgresql.conf, Postgres binds to 127.0.0.1:5433. If I change the port to some other different number, e.g. 5431 it indeed changes to listening on that port. I have checked with lsof and netstat that when Pgsql is down, nothing listens on that port.

How can I fix that?

Platform: Ubuntu 22.04.

UPDATE:

# pg_lsclusters Ver Cluster Port Status Owner Data directory Log file 14 main 5431 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log 
# find / -name postmaster 2>/dev/null /usr/lib/postgresql/14/bin/postmaster /usr/lib/postgresql/14/lib/bitcode/postgres/postmaster 
6
  • I would start by checking the postgresql logs to see why. If not, use strace and ltrace. Make sure you are changing the right configuration file. Commented Aug 13 at 16:31
  • Sometimes a start up script, a systemd service unit, is configured to append commandline options to the daemon that gets started. Maybe in your case the Postgres port gets set on the start up command line overriding the one in the config file Commented Aug 14 at 7:55
  • run pg_lsclusters also sudo find / -name postmaster and post results Commented Aug 14 at 10:27
  • @Jasen Updated. Commented Aug 14 at 12:12
  • that excludes the possibilites I was thinking of. maybe sudo lsof -n | fgrep '(LISTEN)' | grep -P 'postgresql|\D5432\D' will be informative. or sudo systemctl restart postgresql may produce something informative in /var/log/postgresql/postgresql-14-main.log. also if you don't actually care what the cause is you could try rebooting. Commented Aug 14 at 21:44

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.