Remotely connecting to Postgres instance using psql command
I resolved this issue using below options ...
- Whitelist your DB host from your network team to make sure you have access to remote host
- Install postgreSQL version 4 or above
- Run below command:
psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME>
I figured it out.
Had to set listen_addresses='*'
in postgresql.conf
to allow for incoming connections from any ip / all ip
psql -h <IP_Address> -p <port_no> -d <database_name> -U <DB_username> -W
-W
option will prompt for password. For example:
psql -h 192.168.1.50 -p 5432 -d testdb -U testuser -W