Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remaining connection slots are reserved for non-replication superuser connections

I currently have a django application, and have a PostgreSQL database. I have researched this error, and have found other answers on Stackoverflow, but none seem to answer my exact question. I am getting this error when a request is made to a server. Note that I am currently running my application locally. A lot of my views contain requests to the database:

django.db.utils.OperationalError: FATAL:  remaining connection slots are reserved for non-replication superuser connections

Here are the configurations for the database that are in my settings.py file:

Any help would be greatly appreciated!

DATABASES = {
    'default': {
        'ENGINE': 'django_postgrespool',
        'NAME': 'database',
        'USER': 'user',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '5432',
        'CONN_MAX_AGE': 0,
    }
}
like image 921
CodeRocks Avatar asked Sep 27 '18 18:09

CodeRocks


1 Answers

You have a connection leak somewhere.

Unless you changed the default settings, you get that message when you try to establish the 98th database connection.

You have to close the connections you don't need any more.

As with all resource leaks, increasing the limit won't hurt, it just buys you time until you hit the ceiling. Plug the hole!

like image 197
Laurenz Albe Avatar answered Sep 17 '22 05:09

Laurenz Albe