# MySQL Too many connections error

If you see the following error in the HPE Morpheus Enterprise UI logs:

```
```
SqlExceptionHelper - Data source rejected establishment of connection,  message from server: "Too many connections"
```
```

it means the number connections between HPE Morpheus Enterprise application and mysql have reached the max\_connections limit set in mysql (default is 151), or the max\_active setting, which limits the number of connections on the HPE Morpheus Enterprise end (default is 150), and the limit needs to be raised, either in HPE Morpheus Enterprise or mysql, or both depending on the number of connections and configuration.

NOTE

The max\_connections setting in mysql and the maximum used connections between an app node and mysql can be viewed in the HPE Morpheus Enterprise ui in the Administration - Health section under Database.

IMPORTANT

In Single HPE Morpheus Enterprise app node configurations, the `max_active` setting on the app node must be less than the `max_connections` setting in mysql.

IMPORTANT

In HA configurations, the `max_active` setting is per app node, and the `max_connections` setting in mysql must be greater than all app nodes `max_active` values combined, ie `(max_active` \* $number\_of\_app\_nodes) <= max\_connections``.

## HPE Morpheus Enterprise `max_active` setting

Edit `/etc/morpheus/morpheus.rb` and add `mysql[‘max_active’] = $value` replacing `$value` with desired desired number of maximum connections allowed by HPE Morpheus Enterprise to mysql. For example, to set max\_active at 150:

```
```
mysql[‘max_active’] = 150
```
```

Replacing 100 with the desired number of maximum connections allowed by HPE Morpheus Enterprise to mysql.

Run `morpheus-ctl reconfigure` for the setting to be applied. Reconfigure will not restart the ui unless additional ram has been added to the appliance host since the previous reconfigure. To edit the max\_active without a reconfigure, update the `max_active` setting in `/opt/morpheus/conf/application.yml`. Please note the default setting of 150 will be applied upon the next reconfigure unless `max_active` is defined as instructed above in the `morpheus.rb` file.

## mysql `max_connections` setting

IMPORTANT

Customers are responsible for configuring and maintaining external databases used by HPE Morpheus Enterprise. This explains how to set the `max_connections` setting, but the value for the setting needs to be established by a customers qualified db admin.

In mysql prompt,

run `mysql> SET GLOBAL max_connections = $value;`

This will immediately write the variable, however it is only a temporary setting that will be overwritten upon restart of the mysql service.

To persist the `max_connections` setting, edit my.cnf, and add `max_connections = $value` replacing `$value` with desired value, ie to set max\_connections at 300 in in my.cnf, add:

```
```
max_connections = 300
```
```
