PostgreSQL: Remote connection from pgadmin4 to a Linux server

Share via:
Remote connection from pgadmin4 to a Linux server running PostgreSQL:

To establish a remote connection from pgadmin4 to a Linux server running PostgreSQL,
Follow the below steps:
1. Install Pgadmin4: First install pgadmin4 on your local machine. You can download it from the official website (https://www.enterprisedb.com/downloads/postgres-postgresql-downloads) and follow the instructions for the installation.
2. Enable remote access on the Linux server:
To allow remote connections, you need to modify the PostgreSQL server’s configuration file.

Modify the below configurations then save and exit the file.

Now, restart the cluster to apply changes.

3. Modify the pg_hba.conf file:
Navigate through the data directory and open the ‘pg_hba.conf’ file.

This file controls the authentication and access rules for PostgreSQL connections.
The entry should specify the IP address or subnet range of the client machine.

Here we alter the IPv4 local connections.
TYPE – host
Database – all  #to access all databases
User – all  # all users can access the database
ADDRESS – 192.168.0.103/0   # provide your client (windows) IP address
Method – trust   # no password needed
Now reload the cluster to modify changes

4. Configure firewall settings:
To allow connection from outside we should alter the firewall configuration.
Firstly, switch to the root user

iptables: Firewall is not running.

 

Setting up password to user:
To alter password to a user. Connect to the plsql database and run the following command.

ALTER ROLE
5. Connect to the remote Server using pgadmin4:
Follow the below steps to Launch Pgadmin4 on your local machine.
♦ Click on “Add New Server” in the top-left corner and select “Create” > “Server”.
♦ Provide a name for the server.

♦ In the “Connection” tab, enter the following information:

Here, Host name/address: IP address of the Linux server.
PORT: PostgreSQL port
Maintenance database: name of the database you want to connect to.
Username: PostgreSQL username with access to the database.
Click on “Save” to save changes.
Now you can see that linux_db server can access the database in Linux server.

 

Author    : Prudhvi Teja
LinkedIn  : http://linkedin.com/in/prudhvi-teja-nagabhyru-715052224
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTExperts is always active on social media platforms.
Facebook  : https://www.facebook.com/ktexperts/
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts
Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment