On this page
What this issue is
Most dynamic sites store pages, products, orders and settings in a database such as MySQL or MariaDB. On every request, the site opens a connection to it. If that connection fails, WordPress shows Error establishing a database connection. Other platforms show a blank page, a 500 error or their own message.
The page you see is often plain white with one line of text. Your header, forms, tracking tags and checkout are all gone, because nothing can be built without data.
Why it costs you leads or sales
While the error shows, nobody can view a landing page, submit a form or pay. If you run ads, you keep paying for clicks that land on an error page. Tracking tags never load either, so the visits may not even appear in your analytics.
The error can also be intermittent. A database that is slightly overloaded may fail for a few visitors and work for others, which makes it easy to miss.
- Ad clickVisitor arrives from your campaign
- Database connectionSite cannot connect to MySQL
- Landing pageShows an error message
- Form or checkoutNever reached
- Lead or orderNot recorded
The site cannot reach the database, so every later step is lost.
Example: a site that normally gets 12 leads an hour drops to zero while the database is unreachable.
How to check if your site has it
Reload the page and the admin
Open the front page and /wp-admin (WordPress). If the admin shows 'One or more database tables are unavailable' or a repair message, the tables are damaged. If both show the connection error, the credentials or server are the likely cause.
Try another device or network
Rule out your own cache or connection. Use a private window or mobile data.
Check your host's status page and control panel
Look for a database or MySQL incident, and check that your database exists and its disk quota is not full.
Test the credentials directly
Log in to phpMyAdmin or run a mysql command with the same user and password found in wp-config.php.
mysql -h localhost -u DB_USER -p DB_NAME -e "SELECT 1;"If this command fails with 'Access denied', the user or password is wrong. If it fails with 'Can't connect', the server is down or the host name is wrong.
How to fix it
Work through the causes in this order. It goes from the most common and cheapest to the least.
Check the credentials
Open wp-config.php and compare DB_NAME, DB_USER, DB_PASSWORD and DB_HOST with the values in your hosting panel. Passwords change after a migration, a host reset or a security rotation.
Check DB_HOST
Most hosts use localhost, but some use a separate server name such as a hostname shown in the panel. Use the exact value your host gives you.
Make sure the database server is running
On shared hosting, contact support or restart MySQL from the panel if available. On a VPS, check the service status and restart it if stopped.
Check disk space and quota
A full disk can crash MySQL. Free space, then restart the service.
Repair the tablesWordPress
If the admin mentions corrupted tables, enable automatic repair, load the repair page once, then remove the setting.
Restore from a backup if needed
If the database was deleted or badly damaged, restore the most recent backup from your host or backup plugin.
define( 'DB_NAME', 'your_database_name' );
define( 'DB_USER', 'your_database_user' );
define( 'DB_PASSWORD', 'your_database_password' );
define( 'DB_HOST', 'localhost' );define( 'WP_ALLOW_REPAIR', true );
// Then visit: https://example.com/wp-admin/maint/repair.php
// Remove this line when finished.Check wp-config.php
Edit it through your host's file manager or SFTP and verify the four DB_ values.
Check the siteurl and tables
In phpMyAdmin, confirm the tables exist (usually prefixed wp_) and the prefix matches $table_prefix in wp-config.php.
Disable plugins if the problem started after an update
Rename the wp-content/plugins folder to test. Heavy plugins can overload the database.
Check your connection settings
Look in your .env file or config for host, port, user, password and database name.
Check the server and limits
Make sure MySQL or MariaDB is running, accepts connections from the app server, and is not at its max connections limit.
Read the logs
The MySQL error log and your application log usually name the exact failure.
Not applicable to your database
Shopify hosts the database for you. If your store is down, check shopifystatus.com and contact Shopify support. A custom app or middleware you host yourself may have its own database error.
Not applicable to your database
Wix manages hosting. Check the Wix status page and contact support. If you use Velo with an external database, check that service instead.
How to confirm it's fixed
- The home page and a landing page load normally.
- You can log in to the admin area.
- Submit a test form and check that the entry appears and the email arrives.
- Run a test checkout up to the payment step.
- Check that your tracking tags fire on the page.
- Clear any page cache so visitors do not get a stale error page.
How to prevent it happening again
- Keep daily backups of files and the database, and test a restore.
- Record database credentials somewhere safe before changing them.
- After any migration, verify wp-config.php straight away.
- Watch disk space and database size.
- Move to a larger plan if traffic regularly overloads the database.
- Monitor your key pages and forms so you hear about outages before customers do.
02:10
Example: the database server stops after the disk fills.
02:11
Every page shows the connection error. Ads keep sending traffic.
08:30
Someone on the team notices when they open the site.
09:00
Space is freed, MySQL restarts and the site recovers.
How FunnelGuard handles this
FunnelGuard detects this issue today. A robot visitor runs your real customer journeys on a schedule, so if a page shows a database error or the journey cannot load, the step fails. Before alerting, FunnelGuard re-checks the failure from a second region, then sends one alert by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause.
It tells you the site is down for visitors. It does not repair the database, so you still follow the steps above. The Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans have a 3-day free trial.
Questions people ask
Why does my website say 'Error establishing a database connection'?
Your site cannot connect to its database. The most common causes are wrong credentials in wp-config.php, a stopped or overloaded database server, a full disk, or corrupted tables.
How do I fix 'Error establishing a database connection' in WordPress?
First verify DB_NAME, DB_USER, DB_PASSWORD and DB_HOST in wp-config.php against your hosting panel. Then confirm the database server is running and has disk space, and repair tables with WP_ALLOW_REPAIR if the admin reports damage.
Can a database connection error happen suddenly with no changes?
Yes. A database server crash, a full disk, a host-side incident or a traffic spike that exhausts connections can all trigger it without any change on your side. Check your host's status page and logs.
Does a database connection error hurt my SEO?
Brief outages usually do little harm, but long or repeated errors can cause search engines to see failing pages and crawl less. The bigger direct cost is lost leads and wasted ad spend.
How do I know if my database is down or just the credentials are wrong?
Try logging in with the same details through phpMyAdmin or the mysql command. 'Access denied' points to wrong credentials, while 'Can't connect' points to the server being down or the wrong host.
Is the WP_ALLOW_REPAIR setting safe to use?
It is safe if you use it briefly. The repair page works without login while the setting is on, so remove the line from wp-config.php once the repair is finished.
How can I get alerted when my site shows a database error?
Use monitoring that loads your pages and journeys on a schedule. FunnelGuard does this with a robot visitor, re-checks failures from a second region and sends one alert with a screenshot and likely cause.
Related issues
- OPS-076Database too many connections under traffic spikesFix guide
- OPS-072Server out of disk space (uploads, sessions fail)Fix guide
- OPS-073Memory / PHP memory_limit exhausted (white screen)Fix guide
- OPS-074CPU throttling / entry process limits on shared hostingFix guide
- OPS-092Hosting migration left old server serving some trafficFix guide
- OPS-084Error display on (PHP warnings shown to visitors)Fix guide