Skip to content
Advertisement

Connection timed out when I try to connect posgrest sql server on digitalocen and azure function

I have a postgres database running on a digital ocean server. The database is protected by a firewall and ssl root certificate, I add the Outbound addresses provided by the Azure Function App to the database firewall and I am passing the certificate through the connection string.

pg_conn = psycopg2.connect(host= os.environ.get("PG_HOST"),database= os.environ.get("PG_DB"), user=os.environ.get("PG_USER"), password=os.environ.get("PG_PASSWORD"), port=os.environ.get("PG_PORT"), sslmode='require', sslrootcert = r'my-proyect/certificate.crt' )

But when I upload my function to the cloud the connection sends a timeout

Connection timed out Is the server running on that host and accepting TCP/IP connections?

Advertisement

Answer

As per my knowledge, A connection time-out error is typically due to connectivity issues or networking issues.

  • Firewall if not allowing the access to the port number which application has.

Here is the tool for troubleshooting these sort of issues is portgry

portqry -n [hostname] -e [port number]

  • you can even add applications to Trusted Resources in Postgry SQL

enter image description here

Here is the document which has complete information about connection time out error.

Advertisement