Getting OperationalError: FATAL: sorry, too many clients already use psycopg2

I get the error OperationalError: FATAL: sorry, too many clients are already using psycopg2. I call the close method on my connection instance after I have finished with it. I'm not sure what could be the reason for this, this is my first experience with python and postgresql, but I have several years of experience working with php, asp.net, mysql and sql servers.

EDIT: I run it locally, if the connections are closed, as it should be, then I only have one connection open at a time. I had a GUI open to the database, but even closed. I get this error. This happens very soon after starting my program. I have a function that I call that returns a connection that opens, for example:

psycopg2.connect (ConnectionString)

thanks

Final Edit: It was my mistake, I recursively called the same method by mistake, which opened the same method again and again. It's been a long day.

+6
python postgresql psycopg2
source share
2 answers

This error means that it says too many clients are connected to postgreSQL. Are you connected to this database only? Are you using an IDE graphical environment? What method do you use to connect? Do you test queries while running the code? any of these things can be a problem. If you are an administrator, you can increase the number of clients, but if the program hangs on it, then this will not help for long.

There are too many reasons why you may have too many clients working simultaneously with the sparse information that you gave us.

+5
source share

Make sure your db connection command is not in any loop. I was getting the same error from my script until I moved my db.database () from my programs, repeating the execution loop.

+1
source share

All Articles