0

I have Azure VM with PostgreSql on it, and I can't connect to it.

  1. I opened a port for TCP in my VM networking in the Azure portal. port

  2. I have installed PostgreSQL on my VM.

  3. listen_addresses = '*' was already set in postgresql.conf

  4. At the end of pg_hba, I added this:

    host    all             all              0.0.0.0/0                       md5
    
    host    all             all              ::/0                            md5
    
  5. Also, with netstat -a I have this and this

  6. additionally, I can access the PostgreSQL server in my VM (as localhost), and I restarted the service a few times.

  7. as a result, I still can't connect to it from my (no VM) PC. I try it like this.

What did I miss?

0

1 Answer 1

0

I tried to reproduce the same in my environment and got results successfully like below:

I Installed same PostgreSQL server like below:

enter image description here

Check the status of the PostgreSQL using below commend:

sudo systemctl status postgresql-15

And try to disable SELINUX config file, to allow access to connecting postgressql instance like below:

Sudo vi /etc/selinux/config

enter image description here

Check whether firewall is active, and try to disable the firewall like below:

sudo systemctl status firewalld
sudo systemctl stop firewalld
sudo systemctl disable firewalld

enter image description here

Make sure to allow the PostgreSQL connection, change the parameter listen_address make sure to remove # before and restart the sql

vi /var/lib/pgsql/15/data/postgresql.conf

enter image description here

Now When I try psql -u username -h hostname and add client Ip to pg_hba.conf

vi /var/lib/pgsql/15/data/pg_hba.conf

enter image description here

And try to add client authentication, range of IP addresses will be able to access your postgres.

Now, when I tried to login with postgresql in Azure vm it got connected successfully like below:

enter image description here

Reference:

ssh - Can't connect to Postgresql on port 5432

Sign up to request clarification or add additional context in comments.

1 Comment

hmm maybe windows server is the reason. Someone should try it there haha. Thank you for the answer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.