0

I installed Psql in azure virtual machine (linux) and Pgadmin-4 in windows VM. When I try to access Psql through Pgadmin getting connection time out error. I enabled all traffic between 2 VMs. when I checked the Pgadmin logs it shown 401 error

enter image description here

enter image description here

In server manager I put off IE Enhanced security configuration. modified postgresql-conf file listen address to * & pg_hba.conf with proper IPs

James Z
  • 12,209
  • 10
  • 24
  • 44
Rahul
  • 1
  • 3

1 Answers1

0

Created SQL in azure Linux virtual machine and accessed in windows Pgadmin-4:

enter image description here

To enable remote configuration using pgadmin

Try to set password to access to Postgres user using below cmd:

sudo -u postgres psql
\password postgres

Now open the psql to connect the request, you can use this psql -U postgres -c 'SHOW config_file' to identify your config file.

sudo vim  /etc/postgresql/12/main/postgresql.conf
sudo vim /etc/postgresql/12/main/pg_hba.conf
sudo systemctl restart postgresql
sudo systemctl status postgresql

enter image description here

Open the config file in connection and authentication click insert localhost with listen_addresses = '*' :

enter image description here

On pg_hba.conf file and add Ip address:

host all all 0.0.0.0/0 md5
host all all ::0/0 md5

enter image description here

Once you restart the PostgreSQL and it will give response with global 5432 and add port in virtual machine:

enter image description here

Now, when I check the connection its connected successfully like below:

psql -d postgres
\conninfo

enter image description here

If still issue persists, you can check this related thread by Leonard AB

Imran
  • 3,875
  • 2
  • 3
  • 12
  • @Rahul, good to accept the solution if it has solved the problem. This is for the benefit of the SO Community, refer SO [Link](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) – Sourav Aug 02 '23 at 05:38