Skip to content

How can I increase maximum connections? (PostgreSQL)

  • Increased Memory Usage: Raising max_connections will increase memory consumption, which may impact performance.
  • Better Alternative – Idle Session Timeout: Instead of increasing connections, consider setting an idle session timeout to close inactive connections automatically.

Option 1: Update via Cloudpepper Dashboard

Section titled “Option 1: Update via Cloudpepper Dashboard”
  1. Go to the PostgreSQL tab of your server in My Cloudpepper.
  2. Locate the max_connections parameter.
  3. Adjust the value as needed.
  4. Click Save to apply the changes.

Option 2: Manually Edit PostgreSQL Configuration

Section titled “Option 2: Manually Edit PostgreSQL Configuration”

You can also change the max_connections setting directly in the PostgreSQL configuration file via SSH.

  • For PostgreSQL 12 (Odoo 11–13):
Terminal window
sudo nano /etc/postgresql/12/main/postgresql.conf
  • For PostgreSQL 14 (Odoo 14–16):
Terminal window
sudo nano /etc/postgresql/14/main/postgresql.conf
  1. Find the line:
max_connections = 100
  1. Adjust the value based on your requirements.
  2. Save the file and exit.

Restart PostgreSQL after making changes:

Terminal window
sudo systemctl restart postgresql

As increasing the maximum connections can increase memory consumption, consider an idle session timeout to close inactive connections automatically instead.

Example:

idle_session_timeout = 5min

This limits idle connections to 5 minutes, keeping the total connection count stable. Good for high-traffic instances with frequent user activity where inactive connections can rapidly accumulate.

  • us (microseconds)
  • ms (milliseconds)
  • s (seconds)
  • min (minutes)
  • h (hours)
  • d (days)

By implementing an idle session timeout, you can often avoid the need to increase max_connections.