Plesk

WordPress website on a Plesk server does not work: Error establishing a database connection

Symptoms

WordPress website on a Plesk server is not accessible with the following error:

Error establishing a database connection

Cause

Database connection credentials do no match the ones in the configuration file.

Resolution

Update the database password using the following procedure:

  1. Log in to Plesk.

  2. Go to Domains > example.com > File Manager and find the wp-config.php file in the domain directory.

  3. Open wp-config.php and find the first lines defining the database, database user, database password and database server address, like the following:

    /** The name of the database for WordPress /
    define('DB_NAME', 'dbname');
    /
    * MySQL database username /
    define('DB_USER', 'username');
    /
    * MySQL database password */
    define('DB_PASSWORD', 'password');
    /** MySQL hostname */
    define('DB_HOST', '203.0.113.2:3306');

  4. Copy the password (without the '' symbols).

  5. Go to Domains > example.com > Databases and click the database user username under the database dbname (see lines from wp-config.php from the previous step for reference).

  6. Paste the password (see step 2) to the New password and Confirm password fields and click OK or Apply.

    Note: In case an error is shown 'Database user name is greater than 16 characters', shorten the user name to under 16 characters on the Database User page in Plesk, and then update the username in wp-config.php accordingly.

  7. Ensure that DB_HOST is set to the hostname or IP address displayed in Domains > example.com > Databases