How to access PostgreSQL Image?

Overview

PostgreSQL, also termed as Postgres, can be considered as a more efficient and relied upon open-source relational database management system (RDBMS) which enables extensibility and SQL compliance. PostgreSQL initially evolved from Ingres database but later named as PostgreSQL to define its support for SQL.

Thousands of businesses utilize PostgreSQL to support payment transactions, heavy website traffic, e-commerce systems, etc. You can also add your own unique functions that you've created using a variety of programming languages, including Java, Python, C++, and others.

Configuring Remote Connections for Hosts

Ubuntu's PostgreSQL 13 default installation only allows connections from localhost. Ideally, distant clients would connect to a central database server in a production environment, but only over a private network. (LAN). In this article, you will find steps to establish remote connections to local hosts using PostgreSQL image file.

1. Complete SSH using your machine IP Address, then login using your credentials for the PostgreSQL server.

2. Your local machine contains the username and password for the PostgreSQL database.

ls
nano bitnami_credentials

3. In the local machine, postgresql.service has been renamed to bitnami.postgresql.service for establishing remote connection. For enabling remote connection, navigate to PostgreSQL directory which is stored at opt/bitnami/postgresql/conf, and edit PostgreSQL configuration file.

cd opt/bitnami/postgresql/conf
nano postgresql.conf

4. Inside PostgreSQL configuration file, you can find Listen address for remotely accessing database, change the Listen address to any particular IP address for connections to a remote server, by default it is set as "*" which means accessible from all servers.

# Listen on all interfaces
listen_addresses = '*'

# Listen on specified private IP address
listen_addresses = '1.1.1.1'

5. Also configure PostgreSQL to accept remote connections from allowed hosts.

nano pg_hba.conf

# Accept from anywhere
host all all 0.0.0.0/0 md5

# Accept from trusted subnet
host all all 10.10.10.0/24 md5

6. After updating the required changes, restart the PostgreSQL service.

sudo systemctl restart bitnami.postgresql.service

7. Check for status of PostgreSQL service, it will active and running.

sudo systemctl status bitnami.postgresql.service

We recommend using a security group and allowing remote access only to that subnet.

Last updated