User epiz_23862135 already has more than 'max_user_connections' active connections

User epiz_23862135

Error: User epiz_23862135 already has more than ‘max_user_connections’ active connections

Most of my scripts are showing this error, but I believe no other user is online as of now. Please help me out ASAP, the System is being tested with real data.

The homepage is actually ok, but after logging in to mysquavero.ga account, that error comes up. but few minutes ago, it was working properly. Please help me out!

See:

6 Likes

I’ve read that, but it was working just a few hours ago. Am trying to put a destructor to the php scripts that are bringing that error to close connections

Can you try reusing a connection? That way you won’t have to keep opening different connections.

4 Likes

Still not working

How so? You say “not working” but provide no detail… is the connection already closed? is the query not working?

Did you enable display_errors?

I assume you’re trying to run SQL queries through a home-grown php class function. In my past experience, I had trouble just running queries themselves.

If you need some help, do you mind elaborating a bit?

4 Likes

I have over 4 classes, php scripts that write up my page, they all fetch data from the database. This is their basic mark up

<?php

class className{
           private $db_one;
           private $db_two;
           //Other Variables
           public function __construct()
           {
                  $this->db_one=mysqli_connect('a','b','c','d');
                  $this->db_two=mysqli_connect('a','b','c','e');
           }
           public function __destruct()
           {
                  mysqli_close($this->db_one);
                  mysqli_close($this->db_two);
           }
           //Other methods that might be  calling these db_variables
}

I wasnt doing this before, I’ve edited to this after coming across this error.

The issue you’re experiencing, as well as the code that’s generating it, is quite similar to a case from a month ago.

The issue is that with your code structured like this, every object instance creates it’s own database connection. And in the example, it even creates two connection for a single class! So if you instantiate, say, five different objects, this can result in 5 (10?) database connections for a single requests, which makes it very easy to hit the connection limit.

The right way to fix this is to only create one database connection per request and use that across all objects and classes. There are few different patterns you can use for this, but the Singleton Pattern (which I explained in that other post) is effective and simple to implement.

6 Likes

Can’t I come across this problem when I move to premium hosting?

The problem will be the same no matter where you host your site. And it will get worse as your site gets more popular.

4 Likes

Correct me if am wrong. The solution to this problem is to open and close the database for each query right?

1 Like

Yes, if you dont want to close you can add much user to db.
And loop possibility connection with try except.

1 Like

How should I add users? Not that I don’t know how to, but I find it kinda a little different with creating users on a local server at home.

Please give me an example. Whether to hard code it or do it in Control Panel.

1 Like

Why don’t try option 1.

Adding users to infinity free account is impossible

1 Like

I think I’ll try to clear this up a little bit.

No. The solution is the exact opposite. Keep the connection open and then close it only when you are done making queries.

In free hosting, your database only gets one user, the epiz_xxxxxxxx account name you were assigned when you created the account.

Read what I wrote above in this post. You can’t add users, and yes we have a modified phpMyAdmin installation, so it will be different from your local server.

Of course! But what do you need an example of? We can try to help you to the best of our abilities, but that’s hard when we don’t know exactly what to help you with.

Again, you can’t add a user here. You have one, that’s enough, and that’s all you’ll get.

Yes, good observation.

7 Likes

You can use, sqlite queue trick, if really no options work. But hard to do.
use sqlite to secondary recording to reduce traffic. lol. :smile:

Am dead :sob:

There is no one else accessing my site right now, why should it keep showing that error? Unless someone has connected to exhaust my user connection limit, could you please check that for me?

Because the code that is running on your site is causing that to happen when there is one visitor, you.

To fix this, please see the post from Admin above.

6 Likes