Error Establishing Database Connection means the website cannot connect to its database server. The application loads, but it fails before retrieving the data needed to generate the page.
This error is common in database-driven platforms such as WordPress. In most cases the cause is incorrect database credentials, a crashed database service, or server resource limits.
Quick Fix
- Reload the page to rule out a temporary server issue.
- Confirm the database server is running.
- Verify database credentials in the configuration file.
- Restart the web server and database service.
- Repair the database if tables are corrupted.
- Check server logs for connection errors.
Most database connection errors are resolved by correcting configuration settings or restoring the database service.
What This Error Actually Means
Dynamic websites store content in a database. Every time a page loads, the application performs a database request.
The typical process looks like this:
- The web server receives a request
- The application connects to the database
- The database returns the requested data
- The server generates the page
If the connection step fails, the application cannot retrieve the required data. Instead of rendering the page, it returns the message Error Establishing Database Connection.
The failure usually occurs before any content is generated, which is why the entire site appears broken.
Common Causes of Database Connection Errors
Incorrect Database Credentials
The application needs four parameters to connect:
- Database name
- Database username
- Database password
- Database host
If any value is incorrect, the connection fails immediately.
Database Server Is Not Running
If the database service crashes or stops responding, applications cannot establish new connections.
This may occur during server maintenance or unexpected failures.
Corrupted Database Tables
Improper shutdowns or interrupted updates can corrupt database tables. When this happens, the database engine may refuse queries.
Server Resource Limits
High traffic can exhaust database resources such as memory or connection limits.
Once the connection limit is reached, new requests are rejected.
Incorrect Database Host
Some hosting providers use custom database hostnames instead of localhost.
If the application points to the wrong host, the connection attempt fails.
How to Fix Error Establishing Database Connection
Step 1 — Verify Database Credentials
Incorrect credentials are the most common cause.
Check the configuration file for these values:
- Database name
- Database username
- Database password
- Database host
In WordPress, these values appear in wp-config.php.
Step 2 — Confirm the Database Service Is Running
If the database server stops, the application cannot connect.
Restart the database service if you have server access:
sudo systemctl restart mysql sudo systemctl restart mariadb
On shared hosting, check the control panel for database status.
Step 3 — Repair the Database
Corrupted tables can prevent normal database operations.
In WordPress you can enable database repair by adding this line to wp-config.php:
define('WP_ALLOW_REPAIR', true);
Then visit:
/wp-admin/maint/repair.php
This tool scans and repairs damaged tables.
Step 4 — Check Database Host Settings
Many hosting providers assign a specific database host.
Examples include:
- localhost
- 127.0.0.1
- mysql.servername.com
Verify the correct value in your hosting dashboard.
Step 5 — Check Database Connection Limits
Database servers restrict the number of simultaneous connections.
If traffic spikes exceed that limit, additional requests fail.
Monitoring tools or database logs usually reveal this problem.
Advanced Troubleshooting
Inspect Database Logs
Database logs often show connection failures, authentication errors, or query timeouts.
Check Firewall Rules
If the database runs on a separate server, firewall rules may block connections.
Verify Database User Permissions
The database user must have permission to access the required tables.
Test Database Connectivity Manually
Use command-line tools or database clients to verify that the server accepts connections.
Does This Error Affect SEO?
Yes. If search engines repeatedly encounter database connection errors, they may temporarily stop crawling the site.
Short outages usually do not affect rankings, but prolonged downtime can reduce indexing and traffic.
Prevention Best Practices
- Monitor database performance.
- Keep regular database backups.
- Limit unnecessary plugins.
- Optimize heavy database queries.
- Upgrade server resources as traffic grows.
Most database connection issues can be prevented with proper monitoring and maintenance.
When to Contact Support
Contact your hosting provider if:
- The database server is offline
- You cannot access database settings
- The error persists after checking credentials
Providing logs and configuration details will help support teams diagnose the issue faster.
FAQ
What causes “Error Establishing Database Connection”?
The most common causes are incorrect credentials, database server downtime, or resource limits.
Is the error caused by the visitor’s browser?
No. The problem occurs on the server side.
Can plugin updates cause database connection errors?
Yes. Updates that modify database configuration may break connections.
Does high traffic cause this error?
Yes. Traffic spikes can exceed database connection limits.
How quickly can the issue be fixed?
Most cases are resolved quickly once the configuration problem or server issue is identified.
Summary
Error Establishing Database Connection occurs when the application cannot connect to the database server required to load the website.
The most common causes include incorrect credentials, database downtime, corrupted tables, or server resource limits. Checking configuration files and server logs usually reveals the root cause quickly.
Related WordPress Errors
If you’re troubleshooting WordPress issues, these guides may help: