Guides and tutorials

Hundreds of tutorials and step by step guides carefully written by our support team.

Error to establish a connection to the database in WordPress

When you consult your web page, the hosted code usually makes a connection to the database (hereinafter DB) to know what content should be displayed. This happens with dynamic pages (e.g. PHP), that is, the content is not always the same. Pages whose content does not change are called static pages (e.g. HTML)

Without a connection to the database the code does not have access to the information source to show your web page and usually shows an error message in the browser, for example: Error when establishing a connection with the database, or its variant in English Error Establishing Database Connection.

enter image description here

How do I fix the problem?

To solve the error, verify the connection data to the database. To do this, use a database manager or the PhpMyAdmin and make sure that the user and password are valid and that they can see the database and its tables. If this is the case, then you must modify the corresponding configuration file.

Here is an example of a WordPress "wp-config.php" file. You can edit it with an FTP client (for example Filezilla) and modify the following connection parameters:

define ('DB_NAME', '**database_name_here**'); -> the name of the DB
define ('DB_USER', '**username_here**'); -> the user of the DB
define ('DB_PASSWORD', '**password_here**'); -> the password of the user of DB
define ('DB_HOST', '**localhost**'); -> you can leave it as' localhost'`

Where do I find the parameters in SW Panel?

You can find them by accessing the dashboard of your Hosting service or Cloud service that has DB and click on DB Management.

What can it be?

Normally it is because the password of the user of the database has been modified through the menu DB Management of the SW Panel and the new password has not been defined in the file wp-config.php. However, it can also be due to:

  • The credentials to access your DB are not correct (common error commented in this manual).
  • The DB may have been deleted by accident.
  • Error installing WordPress, or in the migration process.
More than 2000 m² of own facilities and Data Centers in Spain
Your privacy is important for us
We use our own cookies for the proper functioning of the site. In addition, third-party cookies are used for analytical purposes only. This information is not associated with any person so that personal identifying data is not stored, but is only information that is collected to identify the session, with the aim of facilitating the analysis of the website. You can change your preferences at any time by entering this website again. For more information about our cookie policy you can visit our Cookies. You can press the "Accept and close" button to give us your consent or you can access more detailed information and manage cookies.
More than 2000 m² of own facilities and Data Centers in Spain
Your privacy is important for us
We use our own cookies for the proper functioning of the site. In addition, third-party cookies are used for analytical purposes only. This information is not associated with any person so that personal identifying data is not stored, but is only information that is collected to identify the session, with the aim of facilitating the analysis of the website. You can change your preferences at any time by entering this website again. For more information about our cookie policy you can visit our Cookies. You can press the "Accept and close" button to give us your consent or you can access more detailed information and manage cookies.