Symptoms
-
The following notification is received via email regarding the WordPress instance
example.com
:Failed to reset cache for the instance: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or we can't contact the database server at ``. This could mean your host's database server is down.
-
The same error is reproduced while trying to scan the instance
example.com
via WP Toolkit. -
The WordPress website
example.com
is up and running.
Cause
Unsupported/customized database connection string set in the wp-config.php
file prevent WP Toolkit from reading the data.
Every WordPress database connection string must be in the form of PHP define
. Other methods like arrays and variables, are not supported.
Resolution
-
Go to Domains > example.com > File Manager
-
Open the
wp-config.php
file. -
Make sure the Database details such as
DB_NAME
,DB_HOST
and user credentials are set with the default method of PHP define. e.g:define( 'DB_NAME', 'wp_dbnameexample' );
define( 'DB_USER', 'wp_userexample' );
define( 'DB_PASSWORD', 'pa$$w0rdExampl3!' );
define( 'DB_HOST', 'localhost:3306' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
Correct the database connection details from SSH
-
Connect to the server via SSH;
-
Navigate to the WordPress directory usually at the domain root path:
# cd /var/www/vhost/example.com/httpdocs
-
Edit the WordPress
wp-config.php
file. Vi editor can be used for this:# vi wp-config.php
-
Make sure the Database details such as
DB_NAME
,DB_HOST
and user credentials are set with the default method of PHP define. e.g:define( 'DB_NAME', 'wp_dbnameexample' );
define( 'DB_USER', 'wp_userexample' );
define( 'DB_PASSWORD', 'pa$$w0rdExampl3!' );
define( 'DB_HOST', 'localhost:3306' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );