Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Error, Too Many Connections

connection

  • Please log in to reply
4 replies to this topic

#1 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1310 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 12:53 PM

A website that I'm one of the developers for got an error, for some reason:
Warning: mysql_connect() [function.mysql-connect]: Too many connections in [I]... some path goes here ...[/I] on line 17

I replaced the path with text in italics, because I don't think the path matters that much.

Here's line 17 of the file it's talking about:
$db = mysql_connect ($host,$name,$code);

Anyone mind explaining to me what's going on and maybe what we can do to prevent this sort of error?
  • 0

#2 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 21 December 2011 - 02:23 PM

Are you using a lot of connections? Sure it's available?

Maybe raising the number in My.cfg?
  • 0

#3 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1310 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 21 December 2011 - 02:29 PM

Well, right now it's working again, but I'm still wondering what could be causing it. I wonder if we're even closing the connection to the database server before exiting the PHP script; in case we're not, could that be the reason?
  • 0

#4 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 21 December 2011 - 02:40 PM

As a practice, I close connections when the operation is complete.

If this is a production DB, it could be some sort of DDoS
  • 0

#5 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 21 December 2011 - 03:12 PM

I wonder if we're even closing the connection to the database server before exiting the PHP script; in case we're not, could that be the reason?

Unless persistent connections are used, the connection to MySQL should automatically drop. This is especially true with classes such as PDO/MySQLi, as the destructor is called upon exit forcing it.

Your issue is entirely dependent on information you have not given us. A shared host may be receiving large holiday traffic, and has reached its limit of connections. Some script may be using persistent connections and none are freed at the end. It could just be that the limit is very low for a shared host and your software may be using too much by connecting every time.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download