Connection to remote machine postgresql database

1.3k views Asked by At

I am trying to connect to a VM ubuntu from my local computer. On the VM I have created a postgresql database. Then I followed all steps that I could find on several tutorial when it comes to allow access for remote connexion to the db:

  • add host all all 0.0.0.0/0 trust to the pg_hba.conf file
  • add listen_addresses = '*' to the postgresql.conf file
  • remove the firewall by executing sudo ufw allow 5432/tcp
  • restart postresql by executing sudo systemctl restart postgresql

By using the command psql and then \c gives You are now connected to database "postgres" as user "postgres". I then create a password by executing ALTER USER postgres WITH PASSWORD 'password';

Then I use postico to connect locally. I want to connect with this same default superuser postgres for testing. I use the VM ip address as host, db name is postgres user postgres, password is password and port 5432 as mentioned above.

After trying to connect for a while with the message opening connection to server, the result is:

could not connect to server: Operation timed out
    Is the server running on host "***.**.**.***" and accepting
    TCP/IP connections on port 5432?

Any help please? I did all steps I could find on many tutorials but still failing to connect.

0

There are 0 answers