Error: Too Many Connections For Role
Issue
The PostgreSQL connector syncs fail with the following error:
FATAL: too many connections for role "<role_name>"
Environment
Connector: PostgreSQL
Cause
This issue occurs when the PostgreSQL role used by Fivetran exceeds its connection limit. PostgreSQL enforces both server-level (max_connections) and role-level (pg_roles.rolconnlimit) limits on concurrent connections.
A PostgreSQL connector may open multiple concurrent connections depending on:
- The number of schemas and tables in the source database.
- Connector rollout or sync duration.
In scenarios where there is a large number of schemas/tables, rollout delays can cause connections to remain open longer, increasing the likelihood of exceeding the role's connection limit.
Resolution
1. Increase Role Connection Limit
Increase the connection limit for the specific role used by Fivetran:
ALTER ROLE <role_name> CONNECTION LIMIT <new_limit>;
This is only safe if the database server can handle more concurrent connections. Ensure your server has sufficient resources before increasing the limit.
2. Increase Server Max Connections
If server resources allow, you can increase the server-level connection limit by adjusting max_connections in postgresql.conf:
- Edit your PostgreSQL configuration file (
postgresql.conf) - Update the
max_connectionsparameter to a higher value - Restart the PostgreSQL server for the changes to take effect
3. Monitor Active Connections
To monitor and identify connection usage patterns, run the following query:
SELECT usename, count(*)
FROM pg_stat_activity
GROUP BY usename;
This helps identify spikes in connection usage and determine appropriate limits for your environment.
Related Information
For more information about PostgreSQL connection management, see: