ERROR: postgresql Connection terminated due to connection timeout

Akash Panda 0 Reputation points
2024-02-06T09:44:47.8433333+00:00

Getting an error as ERROR: postgresql Connection terminated due to connection timeout

pool = new Pool({

            max: 300,

            connectionTimeoutMillis: 5000,

            host: 'c-abxxxfg.22ps25nxx7gjw5.postgres.cosmos.azure.com',

            port: 5432,

            user: 'citus',

            password: 'xxxxxxxx',

            database: 'citus',

            ssl: true,

        });

Using next ts for development.

can anybody help?

Azure SQL Database
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
713 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,442 questions
Azure Database for PostgreSQL
{count} votes

2 answers

Sort by: Most helpful
  1. ShaktiSingh-MSFT 13,346 Reputation points Microsoft Employee
    2024-02-06T13:23:51.4533333+00:00

    Hi Akash Panda •,

    Welcome to Microsoft Q&A forum.

    As I understand, you are getting Timeout issue in Azure Database for PostgreSQL.

    What is the Region in which this server was created?

    What is the configuration of the Flexible Server?

    Transient errors occur when maintenance is performed, the system encounters an error with the hardware or software, or you change the vCores or service tier of your server. The Azure Database for PostgreSQL service has built-in high availability and is designed to mitigate these types of problems automatically. However, your application loses its connection to the server for a short period of time of typically less than 60 seconds at most. Some events can occasionally take longer to mitigate, such as when a large transaction causes a long-running recovery.

    Also refer to https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-limits https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-troubleshoot-common-connection-issues Thanks.

    0 comments No comments

  2. ShaktiSingh-MSFT 13,346 Reputation points Microsoft Employee
    2024-02-07T10:36:49.04+00:00

    Hi Akash Panda •,

    Thanks for the details.

    It looks the error is persistent.

    If the application persistently fails to connect to Azure Cosmos DB for PostgreSQL, the most common causes are firewall misconfiguration or user error.

    • Coordinator node firewall configuration: Make sure that the server firewall is configured to allow connections from your client, including proxy servers and gateways.
    • Client firewall configuration: The firewall on your client must allow connections to your database server. Some firewalls require allowing not only application by name, but allowing the IP addresses and ports of the server.
    • User error: Double-check the connection string. You might have mistyped parameters like the server name. You can find connection strings for various language frameworks and psql in the Azure portal. Go to the Connection strings page in your cluster. Also keep in mind that clusters have only one database and its predefined name is citus.

    Steps to resolve persistent connectivity issues

    1. Set up firewall rules to allow the client IP address. For temporary testing purposes only, set up a firewall rule using 0.0.0.0 as the starting IP address and using 255.255.255.255 as the ending IP address. That rule opens the server to all IP addresses. If the rule resolves your connectivity issue, remove it and create a firewall rule for an appropriately limited IP address or address range.
    2. On all firewalls between the client and the internet, make sure that port 5432 is open for outbound connections (and 6432 if using connection pooling).
    3. Verify your connection string and other connection settings.
    4. Check the service health in the dashboard.

    Hope this helps. Let us know if above does not help, we will investigate further.

    Thanks

    0 comments No comments