Postgres DB ran out of connections and now won't start

Josh Knepfle 0 Reputation points
2025-03-06T21:39:01.7733333+00:00

We had an out of control process create a bunch of connections to our Postgres db. After that we were unable to connect to that database. So, we tried stopping the database. Now it is hung, and we can't stop nor start it. Any help?

Azure Database for PostgreSQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Saraswathi Devadula 160 Reputation points Microsoft External Staff
    2025-03-06T23:41:53.7233333+00:00

    Hello @Josh Knepfle

    Welcome to the Microsoft Q&A Platform! Thank you for reaching out with your question.

    We understand that you encountered an issue where your Azure PostgreSQL Flexible Server got stuck in a hung state when you tried to stop it due to a lack of connections. After our discussion via private message, you confirmed that your server has been successfully stopped, restarted, and is now back online. I'm very pleased to hear that your issue has been resolved.

    For more information, please refer to this document:
    https://techcommunity.microsoft.com/blog/adforpostgresql/why-restarting-azure-database-for-postgresql-took-long/1885780

    **
    Check Connection Limit**: To prevent running out of connections in the future, you can check your max_connections parameter on parameters page for Azure Database for PostgreSQL – Flexible Server.  You can tune max_connections on Postgres Flexible Server, where it can be set to 5,000 maximum connections. 

    Monitor Connections: You can monitor the current connections to the PostgreSQL database using the following SQL query: ```SQL SELECT * FROM pg_stat_activity;

    By following these steps, you should be able to adjust the connection settings to prevent this issue in the future.

    If the issue persists, please let us know here. We will provide more details and do our best to assist you further.

    Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.