psql ignores server port setting through alter system when connecting?

Started by Wim Bertelsover 8 years ago2 messagesbugs
Jump to latest
#1Wim Bertels
wim.bertels@ucll.be

Hallo,

i tested this on two debian stable machines with the apt.postgresql.org
repo enabled. Can anyone confirm this?

Version: 10.1-1.pgdg90+1

Steps to reproduce

1. connect to your db using a unix socket, for example
$ psql --cluster 10/main postgres

2. change the port with alter system, for example
# ALTER SYSTEM set port TO 54331;

3. restart the cluster
# pg_ctlcluster 10 main restart

4. check
# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.6 main 5432 online postgres /var/lib/postgresql/9.6/main
/var/log/postgresql/postgresql-9.6-main.log
10 main 54331 online postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log

5. try to connect again as in 1.
$ psql --cluster 10/main postgres
psql: could not connect to server: Bestand of map bestaat niet
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?

6. check again
$ ss -a | grep 5433
u_str LISTEN 0 128 /var/run/postgresql/.s.PGSQL.54331
554855 * 0
tcp LISTEN 0 128 127.0.0.1:54331 *:*

tcp LISTEN 0 128 ::1:54331 :::*

Background:
The port in postmaster.conf was always 5433 in this test case, also a
non standard port to try to pinpoint the problem closer.

hth,
Wim

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Wim Bertels (#1)
Re: psql ignores server port setting through alter system when connecting?

Wim Bertels <wim.bertels@ucll.be> writes:

i tested this on two debian stable machines with the apt.postgresql.org
repo enabled. Can anyone confirm this?

How would you expect psql to know about a server setting before
connecting?

regards, tom lane