Does someone have an idea about how to change default port for PostgreSQL 9.5, I did the same on previous versions and I just modify the following files:
/var/lib/pgsql/9.5/data/postgresql.conf
listen_addresses = '*'
port = 4000
/etc/phpPgAdmin/config.inc.php
$conf['servers'][0]['host'] = 'localhost';
$conf['servers'][0]['port'] = 4000;
I am using phpPgAdmin to check out the Database from the web, it works with default port, but it doesn't work when not using the default port, also in the terminal i get this error after restarting postgresql service:
[root@cos7psql01 system]# su - postgres
Last login: Sun Jan 17 12:38:27 CST 2016 on pts/0
-bash-4.2$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
*Port set to 4000 is just an example.
Thanks in advance!
Best Answer
Your config setup looks ok, however how you are trying to connect to the service doesn't. If you don't specify a custom port, it will try to connect via the default port.
Try using the
-p
flag to define that you want to connect via a specific port: