0

I began receiving these errors consistently after running a script that collects and stores data in psql:

Could not connect because of FATAL: remaining connection slots are reserved for non-replication superuser connections

I am running psql on Ubuntu. So I decided to restart psql with:

sudo service postgresql restart

Now however, psql has shut down completely

Could not connect because of could not connect to server: Connection refused
        Is the server running on host "localhost" (127.0.0.1) and accepting
        TCP/IP connections on port 5432?

I am completely new to maintaining psql on a server and would be grateful for any advice.

Where do I even begin to solve this problem? How can I get psql to start again without losing any data that is in this massive database?

2
  • something is occupying all the connections. connect at postgres (or other super-user) and do select * from pg_stat_activity; to see what's going on.
    – Jasen
    May 5, 2018 at 6:38
  • Consult the latest server logs inside /var/log/postgresql May 5, 2018 at 8:40

1 Answer 1

1

I began receiving these errors consistently after running a script that collects and stores data in psql:

Your max_connections is too low, or that script isn't dying or releasing the connection.

If you're getting Connection refused after you restart, then perhaps you have multiple copies of postgresql installed on the same machine and you mean to connect to a different port (like 5433). If you're using Ubuntu or Debian run pg_lsclusters and paste the output.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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