How to fix error establishing a database connection
The error establishing a database connection is a common issue that happens when a site refuses to connect to the WordPress database. This video explains four methods to fix the error by establishing a database connection.
The
error establishing a database connection often happens after migrating a
WordPress website, when it refuses to connect to the WordPress database.
Here
are some of the main reasons behind this error message:
The
database login credentials are incorrect
The
database server is down
Some
of the core files are corrupted
Error establishing a database connection WordPress
Here
are four methods to fix the error establishing a database connection in
WordPress:
Match
the database login credentials
Check
whether the database login settings match the ones in your wp-config.php file
using your FTP client or File Manager. This video explains how to do this using
CPanel.
Edit
these lines of code to match the database information:
define('DB_NAME',
'fill_this_with_your_current_database_name');
define('DB_USER',
'fill_this_with_your_current_username');
define('DB_HOST',
'fill_this_with_your_current_localhost');
Make
sure your domain is pointing to your host provider
Make sure your domain is correctly pointing to your web host. Use a WHOIS lookup tool and your hosting control panel to check the nameservers.
Check
your database server
This
error can also appear if your MySQL server is down. If the database server
reaches its maximum capacity, it will not be able to handle more connections.
To check your database server using PHP, find the code in our Hostinger
Tutorial linked in the Handy Links section.
Fix
the corrupted files
Check
your themes and plugins to see if any of them is not working properly. If the
error message showed up after you activated a new theme or plugin, we recommend
deactivating and deleting it.