Articles in this section

Plesk and/or websites are inaccessible: SQLSTATE[08004] [1040] Too many connections error

kb: technical Plesk ABT: Group A MG:7f2078458930ebc659fcb75688c866c1 MT:1751d5edcca5340f78144a4499e8c1d5 FR:PPM-2079

Symptoms

  • The following error message appears in the Plesk interface or during Plesk migration process:

    Unable to connect to database: Too many connections
    SQLSTATE[08004] [1040] Too many connections


    ODBC error #HY000: [unixODBC][ma-3.0.8]Too many connections

  • Websites fail to load with the error:

    Error Establishing a Database Connection

  • Plesk license installation fails with the error:

    Incorrect ServerInfo format (Error code: 2)

    exit status 1

Cause

The maximum number of simultaneous connections to the MySQL databases has been reached and new connections to the server cannot be established.

Resolution

For Plesk on Linux

Note: On Linux server with MySQL installed, the max_connections limit cannot be higher than 214, unless the solution from this KB article is applied.

# Automatic Solution

    1. Connect to the Plesk server via SSH.

    2. Download the script that will set the MySQL parameter max_connections to 300:

      # wget https://raw.githubusercontent.com/plesk/kb-scripts/master/mysql-max-connections/mysql-max-connections.sh

    3. Make the script executable:

      # chmod +x mysql-max-connections.sh

    4. Execute the script:

      # ./mysql-max-connections.sh

Note: If the automatic solution did not help, apply the manual solution below.

# Manual Solution

  1. Connect to the Plesk server via SSH.

  2. Find the current max_connections value:

    # plesk db "SHOW VARIABLES LIKE 'max_connections'"
    +-----------------+-------+
    | Variable_name | Value |
    +-----------------+-------+
    | max_connections | 151 |
    +-----------------+-------+

  3. Open the MySQL configuration file my.cnf in a text editor. In this example, we are using the vi editor:

    • on CentOS/RHEL-based distributions

      # vi /etc/my.cnf

    • on Debian/Ubuntu-based distributions

      # vi /etc/mysql/my.cnf

  4. Increase the number of connections by adding this directive under the [MySQLD] section:

    [mysqld]
    max_connections=300

  5. Save the changes and close the file.

  6. Restart MySQL/MariaDB service to apply the changes using one of these commands:

    # service mysql restart

    # service mariadb restart

For Plesk on Windows Server
  1. Connect to the Plesk server via RDP.

  2. Open the MySQL configuration file %plesk_dir%Databases\MySQL\my.ini in a text editor.

  3. Increase the number of connections by adding this directive under the [MySQLD] section (the default value is 300):

    [MySQLD]
    max_connections=300

  4. Save the changes and close the file.

  5. Restart the MySQL/MariaDB service Plesk Management Service using Windows Plesk Services Monitor

Was this article helpful?

Comments

2 comments
Date Votes
  • Instead of restarting MySQL/MariaDB, you could simply run:

    plesk db "SET @@GLOBAL.max_connections=300;"


    This should immediately increase the max_connections setting to 300 without restarting the database service.

    0
  • I cannot access my plesk account due to Server Error 500 Exception ODBC error #HY000: [ma-3.2.6]Too many connections

    0

Please sign in to leave a comment.