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>
How do you connect to a PostgreSQL database... locally installed as part of third-party software?
Connect to Postgres Database
How to connect react app with postgresql database without server?
Connecting to a localhost postgres database from within a docker container
Should this 127.0.0.1:5432 be 0.0.0.0:5432?
More on reddit.comVideos
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>
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
Former engineer here, unfamiliar with PostgreSQL.
I recently licensed some software that sits atop a PostgreSQL database. It's locally installed on a Windows Server. I'd like the ability to view and run queries against this DB but I can't seem to figure out how to connect to the damn thing directly. I can see the DB files saved in the softwares directory, I've tried "googling it", and have poked around some of the PG config files but... I got nothing but errors.
I'm attempting a connect via pgAdmin. Please take a look at =what I've tried below and the responses thus far. It feels like I'm just shooting in the dark here... any help would be super appreciated! Thanks in advance!
Here is what I've tried:
-
Host name: 'http://[servername].local:33000' (this is what the licensed software points itself to)...
-
Port: 33000
-
-
Host name: 'localhost'
-
Port 33000
-
Host name: 'localhost'
-
Port: 5532
For this last attempt, I found an article that suggested I need to enable the 'listen_addresses' and 'port' lines in the PostgreSQL configuration file (see below)... presumably that means removing the leading '#' for each line, so I did. In fact, I changed the 'localhost' to '*' just for fun. And yet... no change.
To open the port 5432 edit your /etc/postgresql/9.1/main/postgresql.conf and change
listen_addresses='localhost'
to
listen_addresses='*'
and restart your DBMS
invoke-rc.d postgresql restart
now you can connect with
$ psql -h hostname -U username -d database
if you are unable to authentify yourself, then you need to give your user access rights to your database
Edit your
/etc/postgresql/9.1/main/pg_hba.conf
and add
host all all all md5
(This is for a wide open access. For stricter control, consult the pg_hba.conf documentation and adjust according to your needs).
Hereafter you need also a reload
invoke-rc.d postgresql reload
I don't need to mention that this is a basic configuration, now you should think about modify your firewall and improve the security of your DBMS.
This does not work anymore, if it ever did :
host all all * md5
The correct possible lines for this are :
host all all 0.0.0.0/0 md5 #ipv4 range
host all all ::0/0 md5 #ipv6 range
host all all all md5 #all ip
Source