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
You will learn how to connect to the PostgreSQL Database Server via client tools including psql and pgAdmin.
Discussions

How do you connect to a PostgreSQL database... locally installed as part of third-party software?
Unfortunately you are only showing the error message of whatever tool you are using to to connect to Postgres, but not the real (and complete) configuration you use to connect to Postgres. If that tool is indeed running on the same computer where Postgres is installed, then connecting to localhost on Port 5432 will work. If that tool runs on a different computer, you would need to make Postgres accept connections from the outside by changing listen_address to '*' - but you have to verify that with your IT department. You can't just open up a database server "to the world". More on reddit.com
🌐 r/PostgreSQL
3
0
July 20, 2022
Connect to Postgres Database
It sounds like you need a back end. For example, maybe node.js. (I've only used node.js when it was included in something else so I don't know anything about setting it up.) Do a google search for "node.js postgres connection". See also https://nodejs.org/en/learn/getting-started/how-to-install-nodejs (I've had bad experiences with php so I can't recommend it.) More on reddit.com
🌐 r/webdev
9
2
June 6, 2024
How to connect react app with postgresql database without server?
🌐 r/reactjs
6
0
August 3, 2023
Connecting to a localhost postgres database from within a docker container

Should this 127.0.0.1:5432 be 0.0.0.0:5432?

More on reddit.com
🌐 r/docker
4
2
June 29, 2021
🌐
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 ...
🌐
PostgreSQL
postgresql.org › docs › 9.1 › app-psql.html
PostgreSQL: Documentation: 9.1: psql
October 27, 2016 - In order to connect to a database you need to know the name of your target database, the host name and port number of the server, and what user name you want to connect as. psql can be told about those parameters via command line options, namely ...
🌐
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
Find elsewhere
🌐
PostgreSQL
postgresql.org
PostgreSQL: The world's most advanced open source database
PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance. There is a wealth of information to be found describing how to install and use PostgreSQL through the official documentation.
🌐
W3Schools
w3schools.com › postgresql › postgresql_getstarted.php
PostgreSQL - Get Started
The suggested username is [postgres], which is correct, at least for me, press [Enter] to accept: Enter the password you chose when you installed the PostgreSQL database, my password is 12345678: The result might look like an error, but if it shows psql (15.2) or any other version, and in the end you see the postgres=# command (and maybe a warning in between), then you have successfully connected to the database!
🌐
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>
🌐
Hasura
hasura.io › blog › top-psql-commands-and-flags-you-need-to-know-postgresql
Top psql commands and flags you need to know | PostgreSQL
PostgreSQL is also one of the most popular & used relational databases. psql is an interface you can access through the terminal to interact with Postgres databases. You can use it to connect to a database, add & read & modify data, check the available databases & fields, run commands from ...
🌐
PostgreSQL
postgresql.org › docs › current › ecpg-connect.html
PostgreSQL: Documentation: 18: 34.2. Managing Database Connections
May 14, 2026 - Once you link an SQL identifier to a connection, you execute dynamic SQL without an AT clause. Note that this option behaves like preprocessor directives, therefore the link is enabled only in the file. ... #include <stdio.h> EXEC SQL BEGIN DECLARE SECTION; char dbname[128]; char *dyn_sql = "SELECT current_database()"; EXEC SQL END DECLARE SECTION; int main(){ EXEC SQL CONNECT TO postgres AS con1; EXEC SQL CONNECT TO testdb AS con2; EXEC SQL AT con1 DECLARE stmt STATEMENT; EXEC SQL PREPARE stmt FROM :dyn_sql; EXEC SQL EXECUTE stmt INTO :dbname; printf("%s\n", dbname); EXEC SQL DISCONNECT ALL; return 0; }
🌐
Microsoft Learn
learn.microsoft.com › en-us › connectors › postgresql
PostgreSQL - Connectors | Microsoft Learn
Access to this page requires authorization. You can try changing directories. PostgreSQL is a relational database management system developed by PostgreSQL Global Development Group. Connect to on-premise PostgreSQL database to read data from tables.
🌐
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 - For a local database: psql <dbname> < <infile>. Run these commands at the terminal, not at the psql prompt. If you’re at the psql prompt, \q to quit or use a different terminal window.
🌐
PostgreSQL
postgresql.org › docs › current › libpq-connect.html
PostgreSQL: Documentation: 18: 32.1. Database Connection Control Functions
May 14, 2026 - This is what PostgreSQL replication connections as well as tools such as pg_basebackup use internally, but it can also be used by third-party applications. For a description of the replication protocol, consult Section 54.4. The following values, which are case-insensitive, are supported: ... The connection goes into physical replication mode. ... The connection goes into logical replication mode, connecting to the database specified in the dbname parameter.
🌐
Benburwell
benburwell.com › posts › how-i-connect-to-postgres-databases
How I Connect to Postgres Databases
December 13, 2022 - Once you create this file, you can connect with psql by simply referencing the service name: ... If you need to use password authentication for your database, and you don't want to keep your passwords in ~/.pg_service.conf, you can use a separate ~/.pgpass file.
🌐
Solutions
solutions.posit.co › connections › db › databases › postgresql
PostgreSQL – Solutions
There are six settings needed to make a connection: Driver - See the Drivers section for setup information ... con <- DBI::dbConnect(odbc::odbc(), Driver = "[your driver's name]", Server = "[your server's path]", Database = "[your database's name]", UID = rstudioapi::askForPassword("Database user"), PWD = rstudioapi::askForPassword("Database password"), Port = 5432)
🌐
Reddit
reddit.com › r/postgresql › how do you connect to a postgresql database... locally installed as part of third-party software?
r/PostgreSQL on Reddit: How do you connect to a PostgreSQL database... locally installed as part of third-party software?
July 20, 2022 -

Former engineer here, unfamiliar with PostgreSQL.

I recently licensed some software that sits atop a PostgreSQL database. It's locally installed on a Windows Server. I'd like the ability to view and run queries against this DB but I can't seem to figure out how to connect to the damn thing directly. I can see the DB files saved in the softwares directory, I've tried "googling it", and have poked around some of the PG config files but... I got nothing but errors.

I'm attempting a connect via pgAdmin. Please take a look at =what I've tried below and the responses thus far. It feels like I'm just shooting in the dark here... any help would be super appreciated! Thanks in advance!

Here is what I've tried:

  • Host name: 'http://[servername].local:33000' (this is what the licensed software points itself to)...

    • Port: 33000

  • Host name: 'localhost'

    • Port 33000

Host name: 'localhost'

  • Port: 5532

For this last attempt, I found an article that suggested I need to enable the 'listen_addresses' and 'port' lines in the PostgreSQL configuration file (see below)... presumably that means removing the leading '#' for each line, so I did. In fact, I changed the 'localhost' to '*' just for fun. And yet... no change.

Top answer
1 of 2
2
Unfortunately you are only showing the error message of whatever tool you are using to to connect to Postgres, but not the real (and complete) configuration you use to connect to Postgres. If that tool is indeed running on the same computer where Postgres is installed, then connecting to localhost on Port 5432 will work. If that tool runs on a different computer, you would need to make Postgres accept connections from the outside by changing listen_address to '*' - but you have to verify that with your IT department. You can't just open up a database server "to the world".
2 of 2
2
Figure out what port/ip the server really listens on. You will have to check the whole configuration not just the top of postgresql.conf. Port can be changed in any place of postgresql.conf, or any included files/directories. Or it can be passed as command line argument when starting Pg. In which case you have to figure out how to check this in windows (in Unix, it's a matter of calling ps auxww | grep postgres. Alternatively find a tool that shows open ports on a machine, with "what is listening on them". In Unix land this is done using netstat or ss tools: =# netstat -ntlp | grep post tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN 1560/postgres which shows that pg on this particular machine listens on ip 127.0.0.1 on port 5433. Finally, pay close attention to details. And I mean close. You wrote: "Port: 5532", but the error message says that you tried to connect to port 5432. These details matter.
🌐
Supabase
supabase.com › docs › guides › database › connecting to your database
Connect to your database | Supabase Docs
1 day 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.