Getting too many connections errors (Mysql)

Avatar
  • updated
  • Answered

I have two heavily Mysql-driven websites (NewJerseyStage.com and ThePenguinRocks.com) and I'm running into this error all morning:


Warning: mysql_pconnect() [function.mysql-pconnect]: Too many connections in /home/newjer13/public_html/gw.inc.php on line 7


Unable to select database


What can I do to prevent this? I've just started promoting my websites, so traffic is going up. Is this a coding issue or could I possibly be hitting the maximum number of users at one time?


The sites have been working fine for years. These errors are just popping up now.

Avatar
johnpaulb-imhs1
Hello newjerseystage, Thank you for your question. As per your warning, you are using pconnect: mysql_pconnect It is not recommended to use persistent mysql connections, because it allows one visitor to make multiple connections. With a regular connect, it will process the connection, then close the connection once it finishes. Here is a link to an article here in our support center that explains persistent connections in better detail. It is likely that bots are crawling your websites, which is normal, and each time they hit a page, it makes a connection. With pconnect it does not close the previous connection, so when a bot hits every page without disconnecting it can use up your connections. If you have any further questions, feel free to post them below, or contact live Tech Support. They are available 24/7 via: Email: [email protected] Phone: 888-321-HOST (4678) 757-416-6575 (Intl.) & Chat (there is a link on the top right). Thank you, -John-Paul