# Postgres, Databases, Heroku

**URL:** <https://forum.djangoproject.com/t/postgres-databases-heroku/9632>\
**Category:** Using Django\
**Created:** [September 9, 2021, 2:53am UTC](https://forum.djangoproject.com/t/postgres-databases-heroku/9632 "2021-09-09T02:53:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daveson217](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/daveson217/32/5773_2.png) [@Daveson217](https://forum.djangoproject.com/u/Daveson217)\
**Post date:** [September 9, 2021, 2:53am UTC](https://forum.djangoproject.com/t/postgres-databases-heroku/9632/1 "2021-09-09T02:53:18Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [September 9, 2021, 2:44pm UTC](https://forum.djangoproject.com/t/postgres-databases-heroku/9632/2 "2021-09-09T14:44:12Z")

</div>

Hi Daveson217,

This means that you don’t have enough database connections to fulfill the requests. Reverting your change to `CONN_MAX_AGE` to be 0 so that it only lasts the lifetime of the request should solve it. Unless you have many dynos and expect a large load on the site, though in that case upgrading the database should be in order.

Alternatively, you can look into using connection pooling. Heroku provides a [pgbouncer buildpack](https://devcenter.heroku.com/articles/best-practices-pgbouncer-configuration) that will help.

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [September 9, 2021, 5:59pm UTC](https://forum.djangoproject.com/t/postgres-databases-heroku/9632/3 "2021-09-09T17:59:01Z")

</div>

Coming back to this, I think the issue is more likely the number of connections rather than `CONN_MAX_AGE` [as per these docs](https://docs.djangoproject.com/en/3.2/ref/databases/#caveats). How many web and worker dynos do you have running?
