0

I am trying to connect to a Remote PostgreSQL Server(WINDOWS 8 Server) from my local machine (WINDOWS 10 Machine) and i am getting connection timeout error.

I have tried following things before posting this question.

  1. Checked and made sure that listen_addresses in postgresql.conf should be set to '*' on the server end.
  2. 2nd thing, allowed any ip address to communicate with host(i know its a bad practice but for development purpose) I have replaced the local host ipaddress with 0.0.0.0/0 in pg_hba.conf file.

Something like below -

# IPv4 local connections:
host    all             all             0.0.0.0/0            scram-sha-256
  1. Whitelisting the PostgreSQL Port number by adding the Port Number - 5433 in the inbound rules section in Windows Firewall Advanced Settings on PostgreSQL Server machine (WIN 8 Server).
  2. After performing above steps, I have restarted the PostgreSQL.

My local environment

WINDOWS 10 Machine
PostgreSQL 14 
PGAdmin4
Port Number - Default 5432

My Server Environment

WINDOWS 8 Machine
PostgreSQL 15
PgAdmin 4
Port Number - Default 5433

I have tried PGAdmin4/PSQL to connect to this remote server but everytime its failing with time out error.

Please let me know what else needs to be done here.

Thanks in advance.

ManojRawat
  • 61
  • 1
  • 8
  • 1
    This is a networking problem, such as with a firewall or NAT. Bad settings for postgresql.conf or pg_hba.conf will not generate connection timeout errors, they will fail in different ways. – jjanes Apr 26 '23 at 15:07
  • Just one more thing, on that Windows Server , a SQL server instance is also running which i can connect with ippadress , username and password from my local machine using SQL Server Management Studio. – ManojRawat Apr 27 '23 at 04:40
  • Thanks @jjanes , yes you are right, its related to some network issue, both the machines (my local and Server machine)are on different networks. I tried connecting the PostgreSQL hosted on the Server machine with some other machine on the same network and I was able to do it successfully. – ManojRawat Apr 27 '23 at 08:32

1 Answers1

0

Answering this as this could be someone else's problem as well.

The problem was not related to postgresql.conf and pg_hba.conf. I checked if the port is open for communication on the WINDOWS server using command netstat -an |find /i "5433" and found that the Port was showing as listening which means its open for communication. The reason was some network issue, the Network on which the remote machine lies is different from the one which my local machine is using and seems like there's a firewall in between which is blocking the Port Number from communication.

Thanks

ManojRawat
  • 61
  • 1
  • 8