0%
Loading ...

Start Consultation

+44-777-423-0475

The “Establishing Database Connection” issue in WordPress occurs when your website is unable to connect to the database, preventing it from loading properly. Follow this step-by-step tutorial to diagnose and fix the issue:

Step 1: Check Your Database Credentials

The most common cause of this issue is incorrect database credentials in your WordPress configuration. To verify your database credentials, access the wp-config.php file in the root directory of your WordPress installation.

Make sure the following database-related constants are correct:

define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');

Ensure that the values for 'your_database_name', 'your_database_user', and 'your_database_password' match the credentials provided by your hosting provider.

Step 2: Check Database Host

The 'DB_HOST' constant is usually set to 'localhost', but some hosting providers may use a different host. If you are unsure about the correct database host, check your hosting provider’s documentation or contact their support.

Step 3: Verify Database Connection

To ensure that the database server is accessible from your server, use a database client tool (e.g., phpMyAdmin) provided by your hosting provider to connect to the database using the same credentials mentioned in the wp-config.php file. If you can’t connect, it indicates a database server issue, and you should contact your hosting provider for assistance.

Step 4: Check Server Resource Limits

Insufficient server resources can also cause the “Establishing Database Connection” issue. Check your server’s resource usage, including CPU, memory, and disk space. If your server is reaching its resource limits, consider upgrading your hosting plan or optimizing your website to reduce resource usage.

Step 5: Test with a Default Theme

Sometimes, the issue can be related to your current theme. To check if the theme is causing the problem, switch to a default WordPress theme (e.g., Twenty Twenty-One). Access your wp-admin dashboard, go to Appearance > Themes, and activate the default theme.

Step 6: Disable Plugins

Conflicting or poorly coded plugins can also lead to database connection issues. To check if a plugin is causing the problem, access your website via FTP or the File Manager in your hosting control panel and navigate to the wp-content folder. Rename the plugins folder to something like plugins-disabled.

After renaming the plugins folder, go back to your website, and the plugins will be deactivated. Check if the “Establishing Database Connection” issue is resolved. If it is, then a plugin was causing the problem.

Step 7: Re-enable Plugins One by One

Now that you’ve identified that a plugin is causing the issue, you’ll need to find the problematic plugin. Rename the plugins-disabled folder back to plugins, and then activate each plugin one by one.

After activating each plugin, refresh your website to see if the issue reappears. If it does, you’ve found the problematic plugin. Deactivate it again and consider finding an alternative or contacting the plugin developer for support.

Step 8: Check Database Server Logs

If the issue persists, it could be related to the database server itself. Contact your hosting provider and ask them to check the database server logs for any error messages or clues as to what might be causing the issue.

Step 9: Seek Professional Help

If you’ve followed all the steps above and are still facing the “Establishing Database Connection” issue, it’s time to seek professional help. Please feel free to Contact us for our professional service for further assistance.