Title: &#8220;Error establishing a database connection&#8221; from wp-db.php
Last modified: March 5, 2018

---

# “Error establishing a database connection” from wp-db.php

 *  [Reggy](https://wordpress.org/support/users/fluxwavez/)
 * (@fluxwavez)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-from-wp-db-php/)
 * Occasionally, my website will experience an “Error establishing a database connection,”
   where the error page specifically cites line 1531 in wp-includes/wp-db.php: [https://i.imgur.com/zXoaCx3.png](https://i.imgur.com/zXoaCx3.png)
 * This is what that line is:
    `mysqli_real_connect( $this->dbh, $host, $this->dbuser,
   $this->dbpassword, null, $port, $socket, $client_flags );`
 * And the whole block of code it’s a part of:
 *     ```
       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 );
       			}
       ```
   
 * I’m not seeing what the issue could be, which is why I’m wondering if this page
   occurs when there’s a problem with my hosting server and not something to do 
   with the database settings. When this error happens, it’ll usually last about
   5-10 minutes before my website returns to normal.
 * It’s been happening infrequently now; maybe once or twice per 2 weeks. If it’s
   any help, when the error happened earlier, I got a similar database error when
   trying to access my website’s forums based on XenForo software: [https://i.imgur.com/K5gXb9t.png](https://i.imgur.com/K5gXb9t.png)
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ferror-establishing-a-database-connection-from-wp-db-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [8 years, 3 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-from-wp-db-php/#post-10040998)
 * My bet is that your host’s mysql server is occasionally getting overloaded. Please
   contact your host and ask them to check their server logs.
 *  Thread Starter [Reggy](https://wordpress.org/support/users/fluxwavez/)
 * (@fluxwavez)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-from-wp-db-php/#post-10043219)
 * I see, so it probably is on my hosting provider’s end after all. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘“Error establishing a database connection” from wp-db.php’ is closed 
to new replies.

## Tags

 * [connection](https://wordpress.org/support/topic-tag/connection/)
 * [database](https://wordpress.org/support/topic-tag/database/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Reggy](https://wordpress.org/support/users/fluxwavez/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/error-establishing-a-database-connection-from-wp-db-php/#post-10043219)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
