See Heroku “psql: FATAL: remaining connection slots are reserved for non-replication superuser connections”:
Heroku sometimes has a problem with database load balancing.
André Laszlo
, markshiz
and me all reported dealing with that in comments on the question.
To save you the support call, here's the response I got from Heroku Support for a similar issue:
Hello,
One of the limitations of the hobby tier databases is unannounced maintenance. Many hobby databases run on a single shared server, and we will occasionally need to restart that server for hardware maintenance purposes, or migrate databases to another server for load balancing. When that happens, you'll see an error in your logs or have problems connecting. If the server is restarting, it might take 15 minutes or more for the database to come back online.
Most apps that maintain a connection pool (like ActiveRecord in Rails) can just open a new connection to the database. However, in some cases an app won't be able to reconnect. If that happens, you can heroku restart your app to bring it back online.
This is one of the reasons we recommend against running hobby databases for critical production applications. Standard and Premium databases include notifications for downtime events, and are much more performant and stable in general. You can use pg:copy to migrate to a standard or premium plan.
If this continues, you can try provisioning a new database (on a different server) with heroku addons:add, then use pg:copy to move the data. Keep in mind that hobby tier rules apply to the $9 basic plan as well as the free database.
Thanks,
Bradley
heroku pgbackups
command to create a backup despite this error. – Shoddy.bat
script in Windows for this:for /l %%x in (1, 1, 100) do ( start psql )
where 100 is desired number of backends. – Fuglemanpg:backups copy
,pg:backups capture
, by connecting to it frompgAdmin
on my own computer, or any other way I could imagine. Evenpg:killall
didn't help. An hour later, I tried again and connections were 50-50, so after a few attempts I had a successfulpg:backups copy
and my app is back in the air. This was... not a fun day. If you googled this, drink a cup of water. – Alaster