Error establishing a database connection in WordPress

Updated on 2026-10-11 19:01:07 355 visits

When you visit a dynamic web page (for example, developed in PHP), the system usually connects to a database (DB) to obtain the information that must be displayed on the screen.

Unlike static pages (such as those created solely in HTML), dynamic pages generate variable content based on the data stored in the database.

If the web page cannot connect correctly to the DB, the browser will display an error message similar to:

  • Error establishing a database connection
  • Error Establishing Database Connection

How to solve the problem?

To resolve this error, you must check that the database connection details are correct.

You can verify this information using:

  • A database manager.
  • PhpMyAdmin.
  • The SWPanel database management panel.

Make sure that:

  • The database user exists.
  • The password is correct.
  • The user has permissions over the database and its tables.

If the data does not match, you will need to update the configuration file of your application or CMS.

Configuration example in WordPress

In WordPress, the connection details are found in the wp-config.php file.

You can edit this file using an FTP client, such as Filezilla, and review the following parameters:

define('DB_NAME', 'database_name_here');       // Database name
define('DB_USER', 'username_here');            // Database user
define('DB_PASSWORD', 'password_here');        // User password
define('DB_HOST', 'localhost');                // Database server

In most cases, the DB_HOST value can remain as localhost.

Where to find the connection details in SWPanel?

You can check the connection parameters by accessing the Dashboard of your Hosting or Cloud service and entering the section: Database Management

From there you will be able to consult:

  • Database name.
  • Associated user.
  • Configured password.
  • User permissions.

Possible causes of the error

The most common causes of this problem are:

  • The database password has been modified from SWPanel and has not been updated in the wp-config.php file.
  • The DB access credentials are incorrect.
  • The database has been accidentally deleted.
  • Error during the installation of WordPress.