Friday , November 22 2024

Remotely Connect PostgreSQL Running on Azure Linux VM

In today’s article, I will explain the topic of Remotely Connect PostgreSQL Running on Azure Linux VM.

In order to do this, we need to edit the pg_hba.conf and postgresql.conf files. These files are located in /etc/postgresql/version_info/main. The version information here varies according to the installed PostgreSQL version information.

On our server, the access method is as follows.

The pg_hba.conf file is located under /etc/postgresql/9.6/main. This file is used to authenticate PostgreSQL client connections.

 

Changes to be made in pg_hba.conf file;

To edit this file, we need to open it with “vi”. The sudo command temporarily grants root privileges to users with standard privileges. Unix and Linux systems have maximum privileges as root user.

In the pg_hba.conf file, there is a section with localhost access starting with 127.0.0.1/32. We modify this section as follows.

This 0.0.0.0/0 information allows us to access without IP limit. As a safety precaution, we need to change this value in our own production systems!

 

Changes to be made in the Postgresql.conf file;

To edit this file, we need to open it with “vi”. The sudo command temporarily grants root privileges to users with standard privileges. Unix and Linux systems have maximum privileges as root user.

In the listen_addresses section, we make listen_addresses = ‘*’ and save the change we made and exit.

After the editing of both files is completed, PostgreSQL Server needs to be restarted. We do this with the following code block.

After the restart of the PostgreSQL Service, we will see that we can access it when we make our definition in PgAdmin.

 

 

 

Loading

About Çağlar Özenç

Leave a Reply

Your email address will not be published. Required fields are marked *