Category: Supabase and databases

Supabase: too many clients already connected to PostgreSQL

Read this guide in Polish

The application periodically stops connecting to the database and logs in too many clients already. The number of direct connections exceeds the instance limit, often when each serverless request opens a new session.

How to determine the source of the error

Check active connections and their sources in metrics and pg stat activity.

Verify whether the code creates a new client on each request and whether the connections are properly released.

What to do step by step

1. Match the way you connect to the serverless model using the recommended pooler and sharing your customers where it is safe.

2 . Enter reasonable parallel limits and timeouts; consider a larger plan only after measurements.

How to check the score

With typical traffic, the number of connections remains stable and queries do not receive an overload error.

What to do

Do not solve the connection leak by just increasing the instance limit.