- Plesk for Linux
The following error appears in the Plesk interface on Linux:
PLESK_INFO: Unable to connect to database: Too many connections
SQLSTATE  Too many connections
This error means that the maximum number of simultaneous connections to the MySQL server has been reached. New connections to the server cannot be established at this time.
Connect to a Plesk server via SSH.
Automatic Solution (Recommended)
Download, unzip and run automatic script that will set max_connections to 300:
# wget https://support.plesk.com/hc/article_attachments/360003572374/maxconn.zip
# unzip maxconn.zip
# chmod +x maxconn
Note: If the automatic solution did not help, apply the manual solution below.
Check the number of current connections to the server, use:
# mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` extended-status | grep Max_used_connections
| Max_used_connections | 11 |
The current connection limit can be found using:
# mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow ` variables | grep 'max.*connections'
| max_connections | 100 |
| max_user_connections | 0 |
In the above example, the maximum number of connections to the server (
max_connections) is set to 100. The maximum number of connections per user (
max_user_connections) is zero, which means unlimited. The default MySQL values can be redefined in the file:
CONFIG_TEXT: /etc/my.cnf For CentOS/RHEL/CloudLinux
/etc/mysql/my.cnf For Debian/Ubuntu
Set it as below under [mysqld] section:
Restart MySQL after
my.cnfhas been modified:
# service mysqld restart (mariadb/mysql)
Warning: if you set the connection limit to a very high value (more than 300), this may affect server performance. It is better to find and rectify the cause of the high MySQL server usage.
You can check which users/requests slow MySQL on all current connections with the following command:
# mysqladmin -uadmin -p`cat /etc/psa/.psa.shadow` processlist
- If the issue persists, restart MySQL, login to Plesk database and set the value:
# plesk db
mysql> SET GLOBAL max_connections = 1024;
- If the issue still persists, make sure that it is enough disk space.
# df -h
# df -i