I recently deployed an app to Heroku using Postgres free tier as database. I am using Django 3.2 Everything was working fine until I started getting a mail with the following error:

Internal Server Error: /
OperationalError at /
FATAL:  remaining connection slots are reserved for non-replication superuser connections

This happens anytime I open the site. It just started doing this. I thought waiting a while would solve the problem, but it didn't.

  1. What does this error mean?
  2. What causes the error?
  3. How can I solve it?

My CONN_MAX_AGE is set to 500.


you might want to check Concurrency and Database Connections in Django

When increasing concurrency by using a multi-process web server like Gunicorn, you must be aware of the number of connection your app holds to the database and how many connections the database can accept. Each process requires a different connection to the database. To accommodate this, there are a number of tools for providing a connection pool that can hold several connections at a time.

what does this mean?

In a nutshell, different tiered databases have different connection limits. The free database being the one with the most restrictive of course, so, for starters, check the different troubleshooting steps from the documentation linked, most notably, the Number of active connections and Bad Connections

  • 1
    Alright. Thanks a lot. I'll do that
    – David.B
    Sep 8 at 15:20
  • did you figure it out?
    – glls
    Sep 8 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.