# Database Keeps Stopping? Fix Out-of-Memory and Disk-Full Crashes

> Sites showing 'Error establishing a database connection' because MySQL or MariaDB keeps stopping? Here's why it happens and how to stop it recurring.

## Symptom: "Error establishing a database connection"

If your sites are showing this message — on one site, or on every site on the server at once — the database service (MySQL or MariaDB) has most likely stopped. This is almost always caused by the server running out of memory or its disk filling up, not by anything wrong with the sites themselves.

## Bring it back now

xCloud's monitoring automatically tries to restart a failed service, including the database, so it may already be recovering on its own. If it isn't:

1. Go to the server's **Management** page.
2. Find the database service (MySQL or MariaDB) in the services list.
3. If it shows as stopped, **enable** it. If it's already running but sites still can't connect, **restart** it instead.

See [How to Manage Your Server Utilities](/docs/how-to-manage-your-server-utilities-with-xcloud/) for the full walkthrough of the services list.

If the service won't stay up after a restart, don't keep repeating it — find the cause below first.

## Find the cause

### Out of memory

The operating system kills processes, including the database, when the server runs out of memory. This isn't necessarily the database's own settings — memory pressure from PHP workers, WordPress cron jobs, scheduled tasks, or a burst of request traffic can all push a server over the edge and take the database down with it.

### Disk full

A full primary disk stops MariaDB outright. Check disk usage on the server; if it's at or near capacity, that's very likely the cause, especially if the database stopped around the same time disk usage climbed. See [Where Did My Disk Space Go?](/docs/where-did-my-disk-space-go-reclaiming-space-from-local-backups-cache-and-dumps/) for where that space usually goes and how to reclaim it. Adding more storage only helps if the database's data or log files are actually moved onto it — attaching extra disk space without relocating what's filling the original disk changes nothing.

## Fix memory pressure

- **Auto-tune MySQL/MariaDB.** This adjusts Max Connections, Max Allowed Packet and the InnoDB Buffer Pool Size for the server's actual resources. See [How to Auto-Tune MySQL/MariaDB Configurations](/docs/auto-tune-mysql-mariadb-configurations/).
- **Lower PHP worker limits.** A site with `pm.max_children` set too high for the server's RAM can starve the database of memory under load — see [How to Configure PHP Settings](/docs/how-to-configure-php-settings/).
- **Review cron jobs and heavy sites.** A scheduled task or a particularly resource-hungry site can be the actual trigger even when the database is what visibly falls over.
- **Add memory or swap, or upgrade the server.** If tuning and reducing load aren't enough, the server needs more headroom — see [how to upgrade your server in xCloud](/docs/how-to-upgrade-your-server-in-xcloud/).

## Fix a full disk

1. Free up space — see [Where Did My Disk Space Go?](/docs/where-did-my-disk-space-go-reclaiming-space-from-local-backups-cache-and-dumps/) for local backups, cache and logs, the usual culprits.
2. Once there's headroom again, restart the database service from the server's **Management** page.

## What not to do

**Do not reinstall the database in place.** It risks losing data rather than fixing the underlying memory or disk problem. If the database won't come back cleanly, restore from a verified backup, or clone the affected site(s) to a new server, before considering anything more drastic — and [contact support](/docs/access-built-in-support-portal-in-xcloud/) if you're not sure which option is safe for your situation.

Still stuck? Contact our [support team](/docs/access-built-in-support-portal-in-xcloud/) for any of your queries.

## Frequently asked questions

### Why did my database stop with no warning?

The two most common causes are the operating system killing the database process under memory pressure, and the server's main disk filling up. Both stop the database abruptly rather than shutting it down gracefully.

### Will adding more storage fix a disk-full crash?

Only if the database's data or logs are actually moved onto that extra storage. Attaching more disk space to the server without relocating the files that were filling the original disk won't help.

### Should I reinstall the database to fix this?

No. Reinstalling in place risks losing data instead of fixing the cause. Restore from a verified backup, or clone the site to a new server, before you consider anything that touches the existing database installation.
