Troubleshooting “Error Establishing a Database Connection” on Your WordPress Site: A Comprehensive Guide
in WordPress Plugins on December 16, 2025
Fixing “Error Establishing a Database Connection” on Your WordPress Website
Encountering the “Error Establishing a Database Connection” message on your WordPress site can be frustrating. This tutorial provides several solutions to help you diagnose and resolve this common issue.

- Method 1: Verify that Required Software is Running
- Method 2: Check the Nginx Error Log
- Method 3: Check if the Database Username and Password are Correct
- Method 4: Restart the Server
Method 1: Verify that Required Software is Running
Make sure that your web server software (like Nginx or Apache) and your database server (like MySQL or MariaDB) are running. If they are stopped, start them.


If PHP is not starting, you can try uninstalling the current version and installing a stable version (e.g., PHP 7.3). After installation, configure your website to use the newly installed PHP version.
Method 2: Check the Nginx Error Log
After adding a website, if you encounter the “Error Establishing a Database Connection” message when accessing the public IP address, follow these steps:
Step 1: Access your web server management panel (e.g., cPanel, Plesk, or a custom panel) and locate the Nginx settings.

Step 2: View the Nginx error log.

If the error log displays “bind() to 0.0.0.0:80 failed (98: Address already in use)”, it indicates that port 80 is being used by another process. Follow the steps below to clear the process using port 80.
Step 3: Install a “Linux Toolbox” (or similar utility) from your server management panel’s software store and configure an SSH password.


Step 4: Allow SSH password login. This might be found in the security settings of your server management panel.


Step 5: Access the SSH terminal through your server management panel and log in with the password you set.

Step 6: Copy and paste the following command into the SSH terminal and press Enter to clear all processes using port 80:
fuser -k 80/tcp

Step 7: Close the SSH terminal window, go back to your server management panel, and restart Nginx.

Step 8: Open your public IP address in a browser. You should now see a “Site Created Successfully” message.

Method 3: Check if the Database Username and Password are Correct
If you see the “Error Establishing a Database Connection” message after installing WordPress, verify that the database username and password are correct.
Step 1: Open your server management panel and navigate to the database section. Note the database name, username, and password.

Step 2: Access the wp-config.php file and check if the database information is correct.



Step 3: If the database information in wp-config.php does not match the information from Step 1, modify the file directly and save it.

If the username and password are correct and you still cannot connect to the database, try restarting the server.
Key Takeaways
- Always ensure your database server (MySQL/MariaDB) is running.
- Double-check the database credentials in your
wp-config.phpfile. - If port 80 is blocked, identify and terminate the process using it.
- Restarting the server can often resolve temporary connectivity issues.
FAQ
- Why am I getting “Error Establishing a Database Connection”? This usually indicates that WordPress cannot connect to your database. This could be due to incorrect credentials, a stopped database server, or network issues.
- How do I find my database credentials? Your database credentials (database name, username, and password) are typically found in your hosting control panel or the
wp-config.phpfile. - What if none of these solutions work? Contact your hosting provider’s support team. They can help you diagnose and resolve more complex issues with your database server.