Too many connections User has exceeded the max_user_connections resource

By April 22, 2013April 19th, 2018Website Domains and Hostings


****Too many connections*”.****

User has exceeded the max_user_connections resource

About the error

On cPanel, MySQL has a “20 concurrent connections” limit per MySQL user to prevent heavy MySQL load on the server and to identify scripts that use unnecessary MySQL connections due to bad coding practices.




These errors can be prevented by making some tweaks in the code of the website:  Use mysql_connect() for connections to MySQL databases in your code. The advantage is the link to the server will be closed as soon as the execution of the script ends, unless it’s closed earlier by explicitly calling mysql_close(). A detailed explanation can be found at http://us3.php.net/manual/en/function.mysql-connect.php

Use of mysql_close() explicitly. Although mysql_connect() closes the connections, use of mysql_close() in conjunction with it would make sure that the connection is definitely closed.
Prevent use of mysql_pconnect(). “pconnect” means “Persistent Connection”, i.e. the connection to the MySQL server will not be closed when the execution of the script ends. Do not attempt to use it in clustered environments.
Please note: mysql_close() will not close links established by mysql_pconnect.

Leave a Reply