What the Message Means
Every WordPress page starts by connecting to the database. When that connection fails, WordPress stops and shows this message instead of the page. Visitors can only wait and reload; the cause is on the server. Work through the checks below in order, because the first ones are the most common.
Step 1: Is the Database Server Running?
sudo systemctl status mariadb
sudo systemctl status mysql
On AlmaLinux and Rocky Linux, MySQL's service is called mysqld. If it is stopped, read why before starting it:
sudo journalctl -u mariadb -n 50
sudo systemctl start mariadb
If it fails to start again, the log lines directly above the failure name the reason.
Step 2: Was It Killed for Memory?
On a small server, a traffic peak can make PHP and the database use all memory. The kernel's OOM killer then stops the process with the highest score, usually a large one and often the database:
sudo journalctl -k | grep -i "killed process"
free -h
journalctl -k shows the current boot only; after a reboot, add -b -1 to read the previous one.
If the database was the victim, see OOM killer in Linux. On servers with 1 or 2 GB of memory, a swap file gives a safety margin: see how to add a swap file. Lowering the number of PHP workers and the database's buffer sizes helps more over time.
Step 3: Is the Disk Full?
df -h
A database cannot write with a full disk and may refuse to start. Clear space safely as described in no space left on device. Do not delete files in the database's data directory to make room.
Step 4: Check the Settings in wp-config.php
grep "DB_" /var/www/example.com/wp-config.php
| Setting | Holds |
|---|---|
DB_NAME | Database name |
DB_USER | Database user |
DB_PASSWORD | That user's password |
DB_HOST | Server, often localhost |
A site moved from another server, or a password changed in only one place, is a frequent cause. localhost connects through the local socket; 127.0.0.1 connects over TCP.
Step 5: Test the Login by Hand
Use the same values from the command line:
mysql -u wp_user -p -h localhost wp_database
If you get a prompt, the login works and the problem is elsewhere. "Access denied" means the user, password, or host does not match: see MySQL access denied for user. A socket error means the server is not listening where the client looks: see MySQL error 2002.
Step 6: Too Many Connections
If the error comes and goes under load, the database may be refusing new connections because all of them are in use. The log or a manual login shows "Too many connections"; the fix is in MySQL too many connections.
Step 7: Damaged Tables
If the front end works but the admin area reports damaged tables, take a backup first:
mysqldump -u wp_user -p wp_database > wp_database.sql
Then, with WP-CLI, run this from the site folder as the user that owns the site files (www-data in this Debian and Ubuntu example). It calls mysqlcheck, which comes with the database client:
sudo -u www-data wp db repair
Without WP-CLI, add define( 'WP_ALLOW_REPAIR', true ); to wp-config.php and open https://example.com/wp-admin/maint/repair.php. That page works without a login, so remove the line as soon as the repair is done. Repair works on MyISAM tables; InnoDB, the default engine, does not support it and runs its own crash recovery when the server starts.