osb1808
osb1808

Reputation: 3

After changing the port number, connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"

  1. I finished install postgresql11 and to change port number

  2. The first file I modified was '/var/lib/pgsql/11/data/postgresql.conf'

#listen_addresses = 'localhost' -> listen_addresses ='*'

#port = 5432 -> port = 9485
  1. The second file I modified was '/var/lib/pgsql/11/data/pg_hba.conf'

the line i added is 'host all all 0.0.0.0/0 md5'

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
host    all             all             0.0.0.0/0               md5
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident

  1. i restarted postgresql server

systemctl restart postgresql-11

  1. Connection from external client to dbeaver works fine.

  2. but local connection is not fine

su - postgres

psql

there is error message

psql: could not connect to server: There is no such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

  1. I can find two files in '/var/run/postgresql'

.s.PGSQL.9485

.s.PGSQL.9485.lock

  1. If Ireturn the port to the original number of 5432, it works normally again.

  2. Please tell me how to fix it

Upvotes: 0

Views: 1420

Answers (2)

Dri372
Dri372

Reputation: 1321

To complete your setup you have to change environment variable PGPORT

PGPORT=9495; export PGPORT;

If not you have to give port number ( -p 9495 ) to every cde (psql, pg_dump, ...)

Upvotes: 1

mike.k
mike.k

Reputation: 3427

psql is not aware of your Postgres settings, it is using the default port 5432.

Try: psql -p 9485

Upvotes: 4

Related Questions