Knowledge Base

Fixing "Error establishing a database connection"

This error means WordPress can't connect to its database. Your content is usually safe. The cause is almost always one of the following.

1. Check for a server issue

Visit our status page at status.paduhost.com. If there's an issue with your server, we're already working on it.

2. Check your database details

This is the most common cause, especially after moving a website from another host.

  1. In File Manager, open wp-config.php in your website folder.
  2. Find these lines:
define( 'DB_NAME', 'yourusername_wp123' );
define( 'DB_USER', 'yourusername_wp123' );
define( 'DB_PASSWORD', 'your-database-password' );
define( 'DB_HOST', 'localhost' );
  1. In DirectAdmin, go to Account Manager > MySQL Management and check that the database and user names match exactly, including your username prefix.
  2. Check that DB_HOST is localhost.

If you're not sure the password is right, set a new password for the database user in MySQL Management, then update DB_PASSWORD in wp-config.php to match.

3. Repair the database

If the details are correct, the database may need repairing.

  1. Add this line to wp-config.php, above the line that says "That's all, stop editing":
define( 'WP_ALLOW_REPAIR', true );
  1. Visit yourdomain.com/wp-admin/maint/repair.php and click Repair Database.
  2. When it's finished, remove the line from wp-config.php. Anyone can use the repair page while it's there.

4. Check your resource usage

If the error comes and goes, your website may be reaching its resource limits during busy periods. See Understanding your resource limits.

Still not working?

Open a Technical Support ticket with your website address and we'll take a look.


We'll do our best to help troubleshoot WordPress, plugins, themes and other third-party software, but for in-depth help, please contact the software's developer or its official support forum.

Please rate this article to help us improve our Knowledge Base.

0 0