Forums

postgres database connection errors

Hi, I'm getting the following error on my web app which uses postgres and accesses via flask-sqlalchemy and psycopg2. Any hints on what to do would be greatly appreciated:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: remaining connection slots are reserved for non-replication superuser connections

It looks like it's hitting the limits on open connections to the database. Even with just 1 or 2 users. Not sure what could be happening.

Since you have a lot of workers for your web app you were probably bumping up against the max connections of the database. I've increased it from the default of 20. Let us know if you keep seeing the error

Thanks so much for your response. How did you do that? i.e. increase the max number of connections to the database? Was it from the sqlalchemy side or is it a toggle on the pythonanywhere side?

It's a command that you can run, but then you need to contact us to reboot the DB server to pick up the extra connections -- this help page has the details.