WordPress shows this message when PHP cannot open a connection to MySQL. It looks alarming, and it usually has a boring cause you can find in five minutes. Work through the list in order; it is ordered by how often each one is the answer.
1. The credentials in wp-config.php are wrong
Open wp-config.php in the site root and look at the four lines:
define('DB_NAME', 'example_db');
define('DB_USER', 'example_user');
define('DB_PASSWORD', 'the-password');
define('DB_HOST', 'localhost');Compare them with the database in Plesk (Databases: the name and user are shown; reset the password there if you are not sure of it and update the file). This is the cause after almost every migration and after every "I changed the database password to be safe".
Test from the command line, if you have shell access:
mysql -u example_user -p'the-password' -h localhost example_db -e "SELECT 1;"Access denied means credentials; Unknown database means the name; a result of 1 means the credentials are fine and the problem is elsewhere.
2. MySQL is not running
sudo systemctl status mariadb # or mysqlIf it is stopped or failed, start it and read why it died:
sudo systemctl start mariadb
sudo journalctl -u mariadb -n 50The commonest reason for MySQL to have died on a small server is being killed by the kernel's out-of-memory handler during a traffic spike — journalctl -k | grep -i "out of memory" confirms it. That is a sizing problem: fewer PHP workers (tuning PHP-FPM), a smaller InnoDB buffer pool, swap, or more RAM.
On shared hosting you cannot see this; if the panel's own database tools also fail, the host's MySQL is down and a ticket is the fix.
3. The disk is full
MySQL refuses to write when the disk is full and connections start failing shortly after.
df -hAnything at 100% is the answer. Clear space (finding what fills the disk), then restart MySQL.
4. A corrupt table
Often after a crash or a full-disk event. The site may load the front page but not the admin, or show the error intermittently. Add to wp-config.php temporarily:
define('WP_ALLOW_REPAIR', true);Visit https://example.com/wp-admin/maint/repair.php, click Repair Database, then remove the line — the page is accessible to anyone while it is set. From the command line:
mysqlcheck -u root -p --auto-repair --check example_db5. Too many connections
Under heavy load, MySQL hits max_connections (default 151) and refuses new ones. The error is intermittent and appears at peak times. Confirm:
mysql -u root -p -e "SHOW STATUS LIKE 'Max_used_connections'; SHOW VARIABLES LIKE 'max_connections';"If the used count equals the limit, raise it modestly in the MySQL config (max_connections = 300) — but the real fix is usually a page cache so fewer requests reach the database, or PHP-FPM workers capped below what MySQL can serve.
6. The database host changed
On a new server or after a host's migration, the database may live at a different host name — 127.0.0.1 instead of localhost (which uses a socket rather than TCP), or a separate database server. Check Plesk's database page for the host, and try 127.0.0.1 in DB_HOST if localhost fails; the socket path may differ.
Reading the real error
WordPress hides the reason by default. Turn on debug logging in wp-config.php:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);Then read wp-content/debug.log — it shows the actual MySQL error (Access denied, Can't connect to local MySQL server through socket, Too many connections) which maps directly to the sections above. Turn it off again afterwards.
When it is a hack
Rarely, wp-config.php has been altered by malware, or the database user was deleted by an attacker. If the credentials look wrong and you did not change them, treat it as an incident: what to do when your site is hacked.
On VPSPioneer shared plans, causes 2, 3 and 5 are monitored and handled on the server before you see them; on a managed VPS the same, plus we will find cause 1 for you after a migration if a ticket says "database error".