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
๐ŸŒ
PostgreSQL
postgresql.org โ€บ docs โ€บ current โ€บ tutorial-accessdb.html
PostgreSQL: Documentation: 18: 1.4. Accessing a Database
May 14, 2026 - The last line printed out by psql is the prompt, and it indicates that psql is listening to you and that you can type SQL queries into a work space maintained by psql. Try out these commands: mydb=> SELECT version(); version -------------------------------------------------------------------โ€‹----------------------- PostgreSQL 18.4 on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit (1 row) mydb=> SELECT current_date; date ------------ 2016-01-07 (1 row) mydb=> SELECT 2 + 2; ?column?
๐ŸŒ
Neon
neon.com โ€บ postgresql โ€บ getting-started โ€บ connect-to-postgresql-database
Connecting to PostgreSQL Database Server
After entering the password correctly, youโ€™ll be connected to the PostgreSQL server. The command prompt will change to something like this: ... In this command, postgres is the default database of a PostgreSQL server.
๐ŸŒ
PostgreSQL
postgresql.org โ€บ docs โ€บ current โ€บ ecpg-sql-connect.html
PostgreSQL: Documentation: 18: CONNECT
May 14, 2026 - EXEC SQL CONNECT TO "connectdb" AS main; EXEC SQL CONNECT TO "connectdb" AS second; EXEC SQL CONNECT TO "unix:postgresql://200.46.204.71/connectdb" AS main USER connectuser; EXEC SQL CONNECT TO "unix:postgresql://localhost/connectdb" AS main USER connectuser; EXEC SQL CONNECT TO 'connectdb' AS main; EXEC SQL CONNECT TO 'unix:postgresql://localhost/connectdb' AS main USER :user; EXEC SQL CONNECT TO :db AS :id; EXEC SQL CONNECT TO :db USER connectuser USING :pw; EXEC SQL CONNECT TO @localhost AS main USER connectdb; EXEC SQL CONNECT TO REGRESSDB1 as main; EXEC SQL CONNECT TO AS main USER connect
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ postgresql-connect-and-access-a-database
PostgreSQL - Connect and Access a Database - GeeksforGeeks
July 23, 2025 - We can access the PostgreSQL database using 'psql' tool or the 'pgAdmin' application. Other than these, we can also connect to the database by writing a custom application, using one of the several available language bindings that support ODBC ...
๐ŸŒ
EnterpriseDB
enterprisedb.com โ€บ postgres-tutorials โ€บ connecting-postgresql-using-psql-and-pgadmin
Connecting PostgreSQL using psql and pgAdmin | EDB
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 the operating systems, you can pass on the specific parameters in the following format: bash-4.2$ psql -h <hostname or ip address> -p <port number of remote machine> -d <database name which you want to connect> -U <username of the database server>
๐ŸŒ
StrongDM
strongdm.com โ€บ blog โ€บ security
How to Connect to a Remote PostgreSQL Database
December 6, 2024 - You have all the required access credentials, such as the database name, hostname, port, username, and password. The default setting for PostgreSQL allows only localhost connections. However, you can adjust a few configuration files to enable external or remote connections.
๐ŸŒ
Amazon Web Services
docs.aws.amazon.com โ€บ amazon rds โ€บ user guide โ€บ amazon rds for postgresql โ€บ connecting to a db instance running the postgresql database engine
Connecting to a DB instance running the PostgreSQL database engine - Amazon Relational Database Service
If the DB instance is available and accessible, you can connect by providing the following information to the SQL client application: The DB instance endpoint, which serves as the host name (DNS name) for the instance. The port on which the DB instance is listening. For PostgreSQL, the default port is 5432. The user name and password for the DB instance. The default 'master username' for PostgreSQL is postgres. The name and password of the database ...
Find elsewhere
๐ŸŒ
Benburwell
benburwell.com โ€บ posts โ€บ how-i-connect-to-postgres-databases
How I Connect to Postgres Databases - Ben Burwell
December 13, 2022 - Instead of needing to remember to use ben as the username for ssh.public.net, and that sshd is actually listening on port 2222, you can add an entry to ~/.ssh/config similar to the way the Postgres service file works: ... You can actually make the Host label anything you want, it doesn't need to be the real name of the server. This can be useful if you don't actually have a DNS name to connect to and you don't want to remember the IP address: Host my-internal-net User ben Port 2222 HostName 192.0.32.7 ยท So now we can connect fairly easily to our database:
๐ŸŒ
KB Hosting
kb.hosting.com โ€บ docs โ€บ connect-to-postgresql-from-the-command-line
Connecting to PostgreSQL using the command line - hosting.com
To connect to PostgreSQL from the command line, follow these steps: Log in to your account using SSH. At the command line, type the following command. Replace dbname with the name of the database, and username with the database username:
๐ŸŒ
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 - If you already created a different user, replace postgres in the command above with your PostgreSQL username. 3. To list existing databases, use the \l meta-command: ... 4. To switch to a different database, type \c followed by the database name. For example, to connect to the template1 database, enter:
๐ŸŒ
AlexHost
alexhost.com โ€บ home โ€บ faq โ€บ administration โ€บ how to connect to a postgresql database: complete guide for all methods
How to Connect to a PostgreSQL Database: Complete Guide for All Methods
1 month ago - Click the New Database Connection button (plug icon in the top toolbar), or go to Database โ†’ New Database Connection. ... From the list of supported databases, select PostgreSQL and click Next.
๐ŸŒ
w3resource
w3resource.com โ€บ PostgreSQL โ€บ connect-to-postgresql-database.php
Connect to PostgreSQL Database on Linux, Windows | w3resource
April 1, 2026 - Redhat based systems like Centos / Fedora : Connect/login as root - user@user-pc:~$ su - postgres user@user-pc:~$ psql psql (9.3.6) Type "help" for help. ... C:\Program Files\PostgreSQL\9.4\bin>psql -U postgres Password for user postgres: psql (9.4.1) Type "help" for help. postgres=# After accessing a PostgreSQL database, you can run SQL queries and more. Here are some common psql commands ยท To view help for psql commands, type \?.
๐ŸŒ
Tutorial Teacher
tutorialsteacher.com โ€บ postgresql โ€บ connect-to-postgresql-database
Connect to PostgreSQL Database using SQL Shell & pgAdmin
First, you need to enter the PostgreSQL server name. if it is on your localhost then press Enter. The default value mentioned in the square bracket e.g. [localhost] is the default server.
๐ŸŒ
PostgreSQL
postgresql.org โ€บ docs โ€บ current โ€บ libpq-connect.html
PostgreSQL: Documentation: 18: 32.1. Database Connection Control Functions
May 14, 2026 - The following functions deal with making a connection to a PostgreSQL backend server. An application program can have several backend connections open at one time. (One reason to do that is to access more than one database.) Each connection is represented by a PGconn object, which is obtained from the function PQconnectdb, PQconnectdbParams, or PQsetdbLogin.
๐ŸŒ
DigitalOcean
docs.digitalocean.com โ€บ connect to postgresql cluster
How to Connect to PostgreSQL Database Clusters | DigitalOcean Documentation
2 weeks ago - Use the format menu in the Connection Details section to display the same connection information in one of three formats: Connection parameters: Separate fields for username, password, host, port, database, and sslmode. Use this format when your client or application expects individual connection settings, such as DataGrip or pgAdmin. Connection string: A single PostgreSQL URI (postgresql://user:password@host:port/database).
๐ŸŒ
Hasura
hasura.io โ€บ learn โ€บ database โ€บ postgresql โ€บ installation โ€บ 4-connect-to-postgresql-database
Connecting to a PostgreSQL database | PostgreSQL Tutorial
The above command connects directly to the database without asking for a password because the connection string already contains it. ... Type "help" for help. ... It's important to mention that the Postgres server should support SSL to use the SSL mode.
๐ŸŒ
Solutions
solutions.posit.co โ€บ connections โ€บ db โ€บ databases โ€บ postgresql
PostgreSQL - Solutions - Posit
This package acts as both the database driver and the DBI interface. The code, and additional information are available in its GitHub repository here: RPostgres. To connect use: library(DBI) # Connect to the default postgres database con <- dbConnect(RPostgres::Postgres())
๐ŸŒ
Supabase
supabase.com โ€บ docs โ€บ guides โ€บ database โ€บ connecting to your database
Connect to your database | Supabase Docs
8 hours ago - The Data APIs allow you to interact with your database using REST or GraphQL requests. You can use these APIs to fetch and insert data from the frontend, as long as you have RLS enabled. ... For convenience, you can also use the Supabase client libraries, which wrap the Data APIs with a developer-friendly interface and automatically handle authentication: ... The direct connection string connects directly to your Postgres instance.
๐ŸŒ
PostgreSQL
postgresql.org โ€บ docs โ€บ current โ€บ ecpg-connect.html
PostgreSQL: Documentation: 18: 34.2. Managing Database Connections
May 14, 2026 - The connection target DEFAULT initiates a connection to the default database under the default user name.