Postgresql | remaining connection slots are reserved for non-replication superuser connections

In my case, I am programming in Go… and got this error message in the system logs, and my app couldn’t get to the DB, until I restarted the database server. I was building this exec in a new OS and a later release of postgresql.

In my case, I found that, simply, for every rows, err := db.Query() call I made, I was NOT doing the corresponding rows.Close() call! Luckily, in psql, if you do a “select * from pg_stat_activity where state=”idle”;” will show the exact queries being made, where the rows weren’t closed. Any sneaky exit or break calls in-between? In my case, there was a simple solution!

Leave a Comment