PHP error: Too Many Connections

Asked

Viewed 117 times

1

I’m getting some messages from my application, from many running connections.

PHP Warning:  mysqli_connect(): (08004/1040): Too many connections in /home/rmour123/public_html/admin/conexao.php on line 31

Below the form I implemented:

    public static function getInstance() {
       if (!isset(self::$db)) {
         try{
             self::$db = mysqli_connect(HOST, USER, PASSWORD, DBNAME);
         } catch (Exception $e) {
             print "Erro: " . $e->getMessage(); 
         }
       }
       return self::$db;  
    } 

The question is this, am I with some slow routine and that is locking the other connections and thus reaching the limit set in MYSQL(In this case 150 connections)? Or is there something else I haven’t noticed?

  • Vc uses shared server?

  • Hi @dvd, I use hostgator service from the simplest. In addition to being shared, I have 2 databases, one wordpress and another application on the same server.

  • That could be it. The database server has a limit and is not being sufficient.

  • What would be the paleactive? Improve the performance of queries, to release faster connections in use?

  • If you tah closing the connections after using them?

  • No, I only close the statement after use in the prepare function().

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.