twerple logo
Loading experience...
twerple logo

Fixing "Error establishing a database connection"

1 min read • Updated 2 weeks ago • Databases

The common causes of this WordPress and PHP error, and how to fix each one.


This error means your website cannot sign in to its database. It almost always comes down to one of these.

1. Wrong connection details

Open your website's configuration file (for WordPress, wp-config.php in public_html) and check:

  • the host is localhost;
  • the database name and user name include the prefix, for example example_shop;
  • the password is correct. If you are not sure, set a new one with Change Password in Databases → MySQL Databases and enter it in the file.

See Database connection details for your website.

2. The database is empty or missing

If you have just moved the site, check in phpMyAdmin that the database contains tables. If not, import your database file.

3. The user is not allowed into the database

In Databases → Database Users, check that the user is enabled and has access to the right database.

4. Your account is out of space

When an account reaches its disk limit, the database may stop accepting changes. Check your usage on the HostPanel dashboard and free some space.

Still showing the error?

Open a support ticket with your website's address. We will check the database server and your account and tell you what we find.

Was this article helpful?