Skip to content

Instantly share code, notes, and snippets.

@govind0229
Last active December 21, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save govind0229/3505a0e0e518f3f18d97db06fff3b065 to your computer and use it in GitHub Desktop.
Save govind0229/3505a0e0e518f3f18d97db06fff3b065 to your computer and use it in GitHub Desktop.
Postgresql connection exceeded issue solve

Postgresql

Bash psql -U postgres -c 'SHOW config_file' psql -U postgres -c 'SHOW config_file' psql -U postgres -c 'SHOW max_connections' `bash

systemctl restart postgresql-12.service

`

@govind0229
Copy link
Author

govind0229 commented Sep 23, 2020

- Postgresql connection exceeded issue solve -

Error snapshots logs from server file = httpd-errro.log

connection = Database.connect(**conn_params) dial functioned error:: FATAL: remaining connection slots are reserved for non-replication superuser connections File "/usr/local/src/f******/f******env/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect <class 'django.db.utils.OperationalError'> dialersession.py 171 conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: FATAL: remaining connection slots are reserved for non-replication superuser connections

Check current running connection:

psql -U postgres -c 'SELECT count(*) FROM pg_stat_activity;'

Check postgresql configuration file location:

psql -U postgres -c 'SHOW config_file'

Edit postgresql.conf file and did bellow changes as required:

vim /var/lib/pgsql/12/data/postgresql.conf

change bellow and save&close

max_connections = 300 # (change requires restart)

# - Memory -
shared_buffers = 384MB                  # min 128kB

Check max_connections from psql status:

psql -U postgres -c 'SHOW max_connections'

Restart postgresql service and other services accordingly:

Note: If possible, to restart server once updated changes into postgresql.conf file.

systemctl restart postgresql-12.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment