• Hi –

    I setup an Amazon Web Services EC2 instance and setup LAMP on it, followed by wordpress.
    Everything runs fine at first, but after several hours of running, wordpress fails due to a problem in wp-db.php.

    I enabled dubugging and got this warning:

    [23-Nov-2016 08:06:42 UTC] PHP Warning:  mysqli_real_connect(): Error while reading greeting packet. PID=5319 in /var/www/html/wp-includes/wp-db.php on line 1529
    [23-Nov-2016 08:06:42 UTC] PHP Warning:  mysqli_real_connect(): (HY000/2006): MySQL server has gone away in /var/www/html/wp-includes/wp-db.php on line 1529

    Line 1529 in wp-db.php reads:

                            if ( WP_DEBUG ) {
                                    mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
                            } else {
                                    @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
                            }
    

    Currently I have host set to ‘localhost’ as recommended by AWS, dbuser is an admin user I created (not root) and dbpassword obviously the users’ password.

    This all works if I restart mysql, but it then proceeds to fail after several hours

Viewing 4 replies - 1 through 4 (of 4 total)
  • This typically happens when the server database server reaches its resource limit. There is a couple things that could cause this issue and a couple solutions you could try.

    Possibles Causes:

    – bad bots using resources by hitting endpoints thus using connections
    – Settings on the server are too low.

    Possible Solutions:

    – Install a security plugin that protects from brute force. The Jetpack plugin is great at for both XMLRPC and normal login.

    – Install a cache plugin to limit the connections to the DB.

    – Increase your settings for MySQL. I found this just by searching – https://stackoverflow.com/questions/11583352/php-mysql-server-has-gone-away

    My personal advise would be to install Jetpack first.

    • This reply was modified 7 years, 11 months ago by Justin Greer.

    Wow thanks, this is what i need also! ??

    Thread Starter cbsblog

    (@cbsblog)

    Thanks, I think jetpack has resolved this!

    Just to double tap on the issue and solution. If the issue was resolved by using Jetpack, then you site was being pinged by things known as bots AKA bad bots. These bots are a normal occurrence and most of the time they will not harm anything.

    Some lower level shared hosting providers just don’t provide enough juice to handle them. If you are ever expecting that your site views are going to be growing, I would look into moving your host or at least upgrading your hosting plan now to avoid issues for real people.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Database connection drops’ is closed to new replies.