I resolved this issue using below options:

  1. Whitelist your DB host from your network team to make sure you have access to remote host
  2. Install postgreSQL version 4 or above
  3. Run below command:
    psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME>
    
Answer from Jagadish S on Stack Overflow
🌐
EnterpriseDB
enterprisedb.com › postgres-tutorials › connecting-postgresql-using-psql-and-pgadmin
Connecting PostgreSQL using psql and pgAdmin | EDB
On Linux, you will explicitly need to pass these parameters at the shell: For PostgreSQL: -bash-4.2$ psql -d postgres -U postgres · For Advanced Server: -bash-4.2$ psql -d edb -U enterprisedb · If connecting to a remote server from any of ...
🌐
Medium
medium.com › cranecloud › connecting-to-a-remote-postgresql-database-779637147abf
Connecting to a remote PostgreSQL database | by Kawere Wagaba | Crane Cloud | Medium
October 7, 2022 - First export/dump the data. pg_dump ... the data into your new database. psql -h <Host> -p <Port> -d <Name> -U <User> -W < <filename.sql> For a local database: psql <dbname> < <infile>. Run these commands at the terminal, not ...
🌐
PhoenixNAP
phoenixnap.com › home › kb › databases › how to connect to a postgresql database from linux or windows
How to Connect to a PostgreSQL Database from Linux or Windows
December 12, 2025 - Learn how to connect to a PostgreSQL database from Linux and Windows using the psql command-line tool or the pgAdmin 4 GUI.
🌐
StrongDM
strongdm.com › blog › security
How to Connect to a Remote PostgreSQL Database
December 6, 2024 - Add a line like this: "host all all <client_IP_address>/32 md5 (Replace <client_IP_address> with the actual IP of the client)." Save the changes and restart PostgreSQL: "sudo systemctl restart postgresql."
🌐
UbuntuMint
ubuntumint.com › home › postgresql › how to connect to postgres database from command line
How to Connect to Postgres Database From Command Line
December 4, 2023 - You can install the psql client tool using package managers like apt, yum, or dnf, or by downloading them directly from the PostgreSQL website. $ sudo apt install postgresql-client OR $ sudo dnf install postgresql
🌐
Naysan
naysan.ca › 2020 › 07 › 19 › postgresql-execute-command-remotely
PostgreSQL: execute command remotely | Naysan Saran
July 19, 2020 - PGPASSWORD=<user-postgresql-password> psql -h <ip/url-of-the-remote-server> -U <user-name> -d <database-name> < /path/to/your/local/file.sql
Find elsewhere
🌐
w3resource
w3resource.com › PostgreSQL › connect-to-postgresql-database.php
Connect to PostgreSQL Database on Linux, Windows | w3resource
April 1, 2026 - Connect to PostgreSQL Database on Linux, Windows: This tutorial shows you various ways to connect to PostgreSQL database on different platform by using interactive terminal program called psql and pgAdmin GUI application.
🌐
DEV Community
dev.to › azayshrestha › a-guide-to-accessing-a-remote-postgresql-database-in-ubuntu-server-3jjc
A Guide to Accessing a Remote PostgreSQL Database in Ubuntu Server - DEV Community
December 3, 2024 - SSH (Secure Shell) is the most ... to connect to your server: "ssh username@server_ip" (replace username with your server's username and server_ip with the IP address of your server)...
🌐
Linux Tip
linuxscrew.com › home › programming › databases › how to connect to postgresql from the linux command line
How to Connect to PostgreSQL from the Linux Command Line
July 24, 2023 - To connect to a remote PostgreSQL server, supply a hostname or IP address: psql -h my_database_server_hsot -p 5432 -d database_name ... Unless you are logged in as the user postgres and connecting to localhost, you will most likely need to specify ...
🌐
Medium
medium.com › @rezaur.official › how-to-configure-postgresql-for-remote-connection-on-linux-in-4-easy-steps-2b5c61334420
How to Configure PostgreSQL for Remote Connection on Linux in 4 Easy Steps | by Rezaur Rahman | Medium
May 27, 2024 - How to Configure PostgreSQL for Remote Connection on Linux in 4 Easy Steps What is remote database connection? Remote database connections allow users to access data from a database that is on a …
🌐
DevArt
blog.devart.com › home › how to › how to configure postgresql for remote connections: a beginner's guide
Allowing Remote Connections in PostgreSQL: 2 Methods of Configuring Database
February 22, 2023 - To open the file from the Linux Terminal, execute: sudo nano /etc/postgresql/12/main/postgresql.conf · Then, find the line #listen_addresses = 'localhost' and uncomment it (remove the # character at the beginning of the line).
🌐
LogRocket
blog.logrocket.com › home › setting up a remote postgres database server on ubuntu 18.04
Setting up a remote Postgres database server on Ubuntu 18.04 - LogRocket Blog
June 4, 2024 - In our case, we are granting all database users access to all databases with any IP address range, thus, letting any IP address connect. Save and exit the file. Next, allow port 5432 through the firewall by executing: ... In this step, you will be connecting to your server from an external machine. Connect to the remote Postgres database by running:
🌐
GitHub
gist.github.com › plembo › 694d1dc86f80fbe7a1ebab59c7114692
Quick setup local postgresql for remote access · GitHub
$ sudo su - postgres -c psql psql (14.4 (Ubuntu 14.4-1.pgdg20.04+1)) Type "help" for help. postgres=# SHOW data_directory; data_directory ---------------- /data1/pgsql/data (1 row) Create a postgresql superuser for your remote sessions (in ...
🌐
A2 Hosting
a2hosting.com › kb › developer-corner › postgresql › remote-postgresql-connections
The Best Web Hosting Services at 20x Speeds | hosting.com
Get the best hosting with premium hardware for speed and reliability. 24/7/365 global support. Try risk-free with our money back guarantee.
🌐
KB Hosting
kb.hosting.com › docs › remote-postgresql-connections
Setting up a remote PostgreSQL connection - hosting.com
3 weeks ago - When the remote server’s command line prompt appears, the SSH tunnel is established and you can use your PostgreSQL client applications on the local computer.For example, if the psql client application is installed on your local computer, you can type the following command to access a database on the hosting.com server.
🌐
DEV Community
dev.to › pheak_pheasa › how-to-configure-postgresql-for-remote-connections-a-beginners-guide-1903
How to allow remote connections to PostgreSQL on Linux - DEV Community
March 2, 2026 - -Add this line: host all all 172.18.0.0/16 md5 or allow all Docker IPs: host all all 172.0.0.0/8 md5 ... To enable traffic on port 5432 through the firewall, execute the following command: sudo ufw allow 5432/tcp ... After completing these steps, you should be able to connect to the PostgreSQL server from a remote machine using a PostgreSQL client.