18.104.22.168.4. max_user_connections error
Each database user can create a limited number of simultaneous database connections. Error «User 'example_db' has exceeded the 'max_user_connections' resource (current value: XX)» occurs due to an attempt to create a new connection in excess of the current limit (indicated in brackets in the error text).
Standard limit values:
- Shared hosting — 50 (at all tariffs). Attention! At exceeding the permissible load the limit can be reduced until the load is brought back to normal.
- Business 2G — 120.
- 4G business — 180.
- Business 6G — 200.
- Business 8G — 200.
- Business 16G — 400.
- Business 32G — 400.
You can change the limit only by switching to a higher tariff businesshosting... It should be borne in mind that a simple change of tariff and an increase in the limit does not guarantee that the problem will be solved. If a site is making too many connections to the database, it is a good idea to first find the root cause of this behavior by examining the code of the site itself. Increasing the limit without analyzing the problem may lead to the fact that the new limit is also quickly exhausted, or other resources (processor or RAM) will be exhausted.
Common causes of the problem
- High consumption of server resources:
- Consumption of dedicated processor resources by 100%.
- Consumption of dedicated RAM at 100%.
- Slow and heavy database queries.
- Lots of database connections created by site scripts or third-party software.
Search for possible causes
- Check for high load indicators on the graphs resource consumption... If there are high values of resource consumption, then it is worth taking measures to eliminate them, because consequence of high load there may be problems in the operation of all sites in the hosting account.
- Large problem requests are recorded and displayed in the hosting control panel in the section «Slow queries»... The reason may be both incorrect compilation of the query, which is already quite difficult from the beginning, or the unoptimized structure of the database. It is worth considering the possibility of optimizing themselves requests and Database.
- If the previous two reasons have been verified, but there are no signs of them, it is worth trying temporarily Change password databases, so that new connections are not created. In this case, after a while, all connections will be completed and it will be possible to connect to the database for further maintenance and search for possible causes. If it is difficult to determine what exactly can cause such a problem, then in all scripts and in all software where this database was used with the same user, gradually change the password for connecting to the current one and check for the recurrence of the problem.