Get Unlimited Free Downloads – Only $9.9

Join Now
Troubleshooting "Error Establishing a Database Connection" on Your WordPress Site: A Comprehensive Guide - Image 1

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.

Database Connection Error
  1. Method 1: Verify that Required Software is Running
  2. Method 2: Check the Nginx Error Log
  3. Method 3: Check if the Database Username and Password are Correct
  4. 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.

Software Running Status
PHP Installation

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.

Nginx Settings

Step 2: View the Nginx error log.

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.

Linux Toolbox Installation
Modify SSH Password

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

SSH Password Login
SSH Management

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

SSH Terminal

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
Fuser Command

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

Restart Nginx

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

Site Created Successfully

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.

Database Information

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

wp-config.php File
wp-config.php File Content
wp-config.php File Content Highlighted

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.

Editing wp-config.php

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.php file.
  • If port 80 is blocked, identify and terminate the process using it.
  • Restarting the server can often resolve temporary connectivity issues.

FAQ

  1. 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.
  2. 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.php file.
  3. 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.

 

Share Your Valuable Opinions

Cart (0)

  • Your cart is empty.