Postgresql how to set max connections, max_connections

  • Last updated: Nov 3, 2023
  • Views: 2672
  • Author: Admin
Postgresql how to set max connections, max_connections

Hello colleagues.

In today's article, I will tell you how to change the max_connections parameter in Postgresql. This setting is used to limit the connection to the database. max_connections is static and that's why you can't just change it in the console, you need to explicitly set it in the configuration file.

 

Article content:

  1. The current values of max_connections.
  2. Change max_connections in postgresql.conf.
  3. We restart the database.
  4. Examination.

 

1. The current values of max_connections.

Before changing max_connections, let's see how many maximum connections are currently set. To do this, use the command in the console:

psql> SHOW max_connections;

As you can see, 400 connections are now established.


 

2. Change max_connections in postgresql.conf.

To change the max_connections parameter, you need to change it in the postgresql.conf configuration file. Find it and change the values.

$. sudo vim $PG_HOME/postgresql.conf

Change the values from 400 to 500, then save and close the file.


 

3. I will restart the database.

$. pg_ctl restart


 

4. Examination.

After we changed the max_connections values from 400 to 500 and restarted the database, we can check the result. We repeat the first step:

psql> SHOW max_connections;

As you can see, everything worked out, the max_connections values were successfully applied.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

PostgreSQL - pg_dump creating backup with bzip2 compression

PostgreSQL - pg_dump creating backup with bzip2 compression

PostgreSQL - how to reset postgres password

PostgreSQL - how to reset postgres password

Download and install Postgresql 14 on Linux CentOS/RHEL 8/7 TAR

Download and install Postgresql 14 on Linux CentOS/RHEL 8/7 TAR