ahmadMarafa ahmadMarafa - 3 months ago 33x
SQL Question

mysqli too many connections (HY000/1040) and (08004/1040) is there a difference?

I'm getting the following errors in my script:

mysqli_connect(): (08004/1040): Too many connections
mysqli_connect(): (HY000/1040): Too many connections

What is the difference and how can I solve this problem?


"Too many connections" indicates, that your script is opening at least more than one connection to the database. Basically, to one server, only one connection is needed. Getting this error is either a misconfiguration of the server (which I assume isn't the case because max connections = zero isn't an option) or some programming errors in your script.

Check for re-openings of your database connections (mysqli_connect). There should only be one per script (!) and usually you should take care of reusing open connections OR close them properly after script execution (mysqli_close)