0

I want to connect my posgresql database using remote ip address but i am getting an error.

psycopg2.OperationalError: connection to server at "178.56.25.266", port 5432 failed: Connection refused (0x0000274D/10061)
    Is the server running on that host and accepting TCP/IP connections?

here also i am sharing my python code.

import psycopg2
conn = psycopg2.connect(database="test", user='postgres', password='', host='178.56.25.266')
cursor = conn.cursor()
cursor.execute("select version()")
data = cursor.fetchone()
print("Connection established to: ",data)
conn.close()

Please help me to resolve this problem.

  • have you tried to scour [this post?](https://stackoverflow.com/questions/40532399/unable-to-connect-to-server-for-postgres) – Alvi15 Dec 09 '22 at 02:17

1 Answers1

0

The postgres server is blocking the IP address of the request, so you need to whitelist it first. If the postgres server is on azure you should be able to add a networking rule with the IP address you want to whitelist, port 5432.

Aware
  • 1
  • 1