Title: Database connection drops
Last modified: November 23, 2016

---

# Database connection drops

 *  [cbsblog](https://wordpress.org/support/users/cbsblog/)
 * (@cbsblog)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/database-connection-drops/)
 * 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)

 *  [Justin Greer](https://wordpress.org/support/users/justingreerbbi/)
 * (@justingreerbbi)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/database-connection-drops/#post-8473053)
 * 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 – [http://stackoverflow.com/questions/11583352/php-mysql-server-has-gone-away](http://stackoverflow.com/questions/11583352/php-mysql-server-has-gone-away)
 * My personal advise would be to install Jetpack first.
    -  This reply was modified 9 years, 6 months ago by [Justin Greer](https://wordpress.org/support/users/justingreerbbi/).
 *  [gurtwicklerelektrisch](https://wordpress.org/support/users/gurtwicklerelektrisch/)
 * (@gurtwicklerelektrisch)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/database-connection-drops/#post-8473065)
 * Wow thanks, this is what i need also! 🙂
 *  Thread Starter [cbsblog](https://wordpress.org/support/users/cbsblog/)
 * (@cbsblog)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/database-connection-drops/#post-8473342)
 * Thanks, I think jetpack has resolved this!
 *  [Justin Greer](https://wordpress.org/support/users/justingreerbbi/)
 * (@justingreerbbi)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/database-connection-drops/#post-8473390)
 * 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.

## Tags

 * [wp-db.php](https://wordpress.org/support/topic-tag/wp-db-php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Justin Greer](https://wordpress.org/support/users/justingreerbbi/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/database-connection-drops/#post-8473390)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
