MySQL: 1040, 'Too many connections' exception
If Hue displays the "1040, Too many connections" exception, then it is possible that
the Hue backend database is overloaded and out of maximum available connections. To resolve
this issue, you can increase the value of the
max_connections property for
The 1040, 'Too many connections' exception occurs on a MySQL database when it runs
out of maximum available connections. If you are using the Impala engine, you may
see the following error message on the Hue web interface:
at /desktop/api2/context/computes/impala("1040: too many connections").
A similar error may be displayed for Hive. The exception is also captured in the Hue
max_connectionsproperty defines the maximum number of connections that a MySQL instance can accept. Uncontrolled number of connections can crash the server. Following are some guidelines for tuning the value of the
- Set the value of the
max_connectionsproperty according to the size of your cluster.
- If you have less than 50 hosts, then you can store more than one database (for example, both the Activity Monitor and Service Monitor) on the same host. If you have more than 50 hosts, then use a separate host for each database/host pair. The hosts need not be reserved exclusively for databases, but each database must be on a separate host.
- For less than 50 hosts:
- Place each database on its own storage volume.
- Allow 100 maximum connections for each database and then add 50 extra connections. For example, for two databases, set the maximum connections to 250. If you store five databases on one host (the databases for Cloudera Manager Server, Activity Monitor, Reports Manager, Atlas, and Hive MetaStore), then set the maximum connections to 550.
To increase the number of maximium available connections and to resolve the "1040, Too many connections" exception:
- Log in to Cloudera Manager and stop the Hue service.
- SSH in to your database instance as a root user.
Check the number of available connections by running the following
grep max_conn /etc/my.cnf/etc/my.cnf is the default location of the options file (
Set the new value of the
max_connectionsproperty from the MySQL shell as per the guidelines provided above. For example:
mysql> SET GLOBAL max_connections = 550;
- Restart the Hue service.