Hello @deedslag
As you said you face “Error Establishing A Database Connection”, which happens when the website refuses to connect to the?WordPress database.
There is a high chance that the issue might be due to insufficient server resources. If not then check the below solutions.
Solutions:
–>Error establishing a database connection
- Check your database server
The error message may arise on your WordPress site when your MySQL server is unavailable. Various factors can generate this error, it commonly occurs due to an excessive number of connections.
A database server has a maximum limit on simultaneous client connections. When this limit is reached, additional connections may be denied. Please reach out to your hosting provider to inspect and address potential issues with your MySQL server.
- Connect to your control panel.
- Inside public_html, create one php file.
- And, add the following code:
<?php
$link = mysqli_connect(‘localhost’, ‘username’, ‘password’);
if (!$link) {
die(‘Could not connect: ‘ . mysqli_error());
}
echo ‘Connected successfully’;
mysqli_close($link);
?>
Replace username, database name and password.
- Access this file in browser
https://domain-name/test.php
- Check the Database Login Credentials
1. Open the file manager from the cPanel account.
2. Open your wp-config.php file.
3. Next, verify this data in your database. For this go to Databases > phpMyAdmin.
4. Make sure that both data should be the same.
- Fix the corrupted files
A corruped theme or plugin is one of the factors that cause file corruption.
Themes:
1. To solve this, navigate to Apperance > Themes from your WordPress dashboard.
2. Choose another theme and check your page, then check whether it solved the issue or not. If not then the issue could be a corrupted plugin. In that case, consider deactivating all plugins and gradually reactivating them one by one to pinpoint the problematic ones.
Plugins:
1. Go to the File Manager.
2. Inside public_html, choose wp-content folder.
3. Rename the plugins folder.
By taking this step, you will deactivate all your plugins simultaneously. The same process can be used for disabling all WordPress themes. However, it is crucial not to disable both themes and plugins concurrently, as this can significantly complicate the process of identifying the root cause of the problem.
If the error disappears after renaming the plugins folder, it indicates that one of the plugins is causing the issue.
4. Repair the database in WordPress
Add the following code in your wp-config.php file.
define(‘WP_ALLOW_REPAIR’, true);
Next go to https://www.your-domain.com/wp-admin/main/repair.php in your web browser.
Two repair options will be presented – select the one that suits your needs.
Once the repair process is over, check your WordPress site to verify if it has returned to its normal state. If successful, promptly remove the function from your wp-config.php file to prevent potential misuse, as the repair page can be accessed by anyone without the need for login credentials.
–>503 error
1. Temporarily Disable Your Content Delivery Network
Occasionally, the 503 error may not originate from an issue on your website but from your Content Delivery Network (CDN). If you use a CDN, a swift method to determine this is to temporarily deactivate it.
2. Review logs and enable WP_DEBUG
Add the following code in your wp-config.php file.
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, false );
3. As above mentioned, disable and re-enable your plugins and theme.