A single cPanel account’s runaway PHP process can exhaust max_connections on the server, locking every other account out of MySQL. The blast radius is the entire host. The defense is max_user_connections — a per-user cap that stops one account from monopolizing the connection pool. Setting it globally protects against the noisy-neighbor pattern but introduces a new failure mode when a legitimate burst (sale, marketing campaign, batch job) needs more connections than the cap allows. Tuning involves knowing what your hosted apps actually do.
What’s happening
MySQL has two connection limits:
max_connections— total simultaneous client connections to the server. Hit this and the next client gets “Too many connections.”max_user_connections— per-account cap. Hit this and the offending account gets “User has exceeded the ‘max_user_connections’ resource.”
The default for max_user_connections is 0 meaning unlimited per-user. On a shared cPanel host, this is the wrong default — one PHP-FPM pool runaway can take down the server’s MySQL for everyone. cPanel does not set this on install, so until you do, the host has no per-user protection.
The correct value depends on workload. For a typical WordPress account, 30–50 concurrent connections is plenty (PHP-FPM with 20 children, each opening one persistent connection, plus headroom). For Magento, double that. For a node.js app with a connection pool of 100, you need 100 plus headroom or the app errors at the pool limit.
How to verify
mysql -e "SHOW VARIABLES LIKE 'max_connections'"
mysql -e "SHOW VARIABLES LIKE 'max_user_connections'"
mysql -e "SELECT USER, MAX_USER_CONNECTIONS FROM mysql.user WHERE USER LIKE '%\\_%'"
mysql -e "SHOW STATUS LIKE 'Max_used_connections%'"
mysql -e "SELECT user, COUNT(*) AS conn FROM information_schema.PROCESSLIST GROUP BY user ORDER BY conn DESC LIMIT 20"
The first two are global caps. The third lists per-user caps from mysql.user. Max_used_connections shows the peak ever reached and when — your headroom check. The PROCESSLIST aggregation shows current per-user concurrency, useful for picking realistic limits.
The fix
- Pick a global default. For a typical cPanel shared host with
max_connections = 500, setmax_user_connections = 50globally:
Restart MySQL. New connections are capped at 50 per account./etc/my.cnf.d/cpanel.cnf: [mysqld] max_user_connections = 50 - Override per-account where needed. A high-traffic Magento store with 200 PHP-FPM children needs more:
This applies permysql -e "ALTER USER 'acmecorp_mage'@'localhost' WITH MAX_USER_CONNECTIONS 200"(user, host)pair, not per username. If the account has_app@localhostand_app@%, each gets its own quota. - Watch for connection pool sizing mismatches. If an app’s connection pool is configured for 100 connections and
max_user_connections = 50, the app errors at 50 with no obvious message. Match the pool size to the cap or vice versa. - Set
max_connectionsheadroom too. With 100 accounts at 50 connections each, the theoretical peak is 5000. Most hosts can’t sustain that much. Pickmax_connectionsbased on what RAM allows (each connection consumes ~10MB on a typical config) and accept that the per-user caps prevent saturating it from one account. - Monitor
Connection_errors_max_connectionsinSHOW STATUS— non-zero means clients hit the global cap. If this climbs, eithermax_connectionsis too low for total traffic, or connection leaks are real and need application-side fixing. - Verify the cap works by running
mysqlslapfrom the affected account, ramping concurrency past the cap, and confirming you see the right error. Better to test than to discover it at 2am.
For multi-tenant cPanel hosts where workloads vary widely and per-account caps need ongoing adjustment, Stack Harbor’s cPanel server administration team correlates PROCESSLIST samples with traffic patterns and ships per-account cap updates as part of the monthly operations review.