I want to understand when this error occurs and how to resolve it. I checked pg_stat_activity and pg_locks but couldnt figure out which process is exhausing the connections
We are using sqlalchemy to connect to database as below
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine_url = f'{dbms}://{username}:{password}@{hostname}:{port}/{database}'
engine = create_engine(engine_url, pool_size=20, max_overflow=10)
Session = sessionmaker(bind=engine)
db_session = Session()
This is an extension of Heroku "psql: FATAL: remaining connection slots are reserved for non-replication superuser connections"
pg_stat_activity. That's all the information about the existing clients you get: process id, client address, user, database. You'll have to investigate the client side. - Laurenz Albelsofto see who holds a network connection to the database. Usepg_terminate_backendto kill database sessions. - Laurenz Albe